I want to create a static private IP address and associate the IP address with the primary node of an Amazon EMR cluster.
Resolution
To create a static private IP address and associate the IP address with your cluster's primary node, use a bootstrap action.
Complete the following steps:
- Confirm that your AWS Identity and Access Management (IAM) policy allows EMR_EC2_DefaultRole and ec2:AssignPrivateIpAddresses permissions.
- Sign in to GitHub on the GitHub website.
- Download the assign_private_ip.py assign_private_ip.py script on the GitHub website.
Note: If you use security configurations to launch your cluster with only IMDSv2 allowed, then download version 2 of the script assign_private_ip_v2.py on the GitHub website.
- Save the script in an Amazon Simple Storage Service (Amazon S3) bucket.
- Specify the script as a custom bootstrap action, and then use the script to launch your cluster. You can also run the script as an Amazon EMR step.
Note: The script requires a private IP address from the CIDR range of your subnet and an AWS Region as an argument. The script attaches that private IP address to the network interface (eth0) of the primary node. The script also configures the network settings to redirect all traffic from the secondary IP address to the primary IP address. It uses the s3://BUCKET_NAME/assign_private_ip.py PRIVATE_IP us-east-1 format.
- To find the new IP address, open the Amazon Elastic Compute Cloud (Amazon EC2) console.
- Select the Amazon EC2 instance that's the primary node of the EMR cluster. You can find the new IP address on the Networking tab, in the Secondary private IPs field.
Related information
How do I determine whether to use a bootstrap action or a step on an Amazon EMR cluster?