How do I assign a static private IP address to the primary node of my Amazon EMR cluster?

2 minute read

I want to create a static private IP address and use a bootstrap action to associate it with the primary node of an Amazon EMR cluster.


To create a static private IP address and use a bootstrap action to associate the IP address with your cluster's primary node, complete the following steps:

  1. Confirm that your AWS Identity and Access Management (IAM) policy allows EMR_EC2_DefaultRole and ec2:AssignPrivateIpAddresses permissions.
  2. Sign in to GitHub.
  3. Download the script from AWS Labs.
  4. Save the script in an Amazon Simple Storage Service (Amazon S3) bucket.
  5. Specify the script as a custom bootstrap action, and then use the script to launch an Amazon EMR cluster. You can also run the script as an Amazon EMR step.
    Note: The script requires an argument that's a private IP address from the CIDR range of your subnet. 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. The script requires a private IP address and the cluster's AWS Region. It uses the s3://BUCKET_NAME/ PRIVATE_IP us-east-1 format. The us-east-1 Region is an example.
  6. To find the new IP address, open the Amazon Elastic Compute Cloud (Amazon EC2) console. Then, select the EC2 instance that acts as the primary node of the EMR cluster. The new IP address appears 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?

AWS OFFICIALUpdated 3 months ago

Just one correction in the above steps,

When you pass the Bootstrap Action script, it requires to two input arguments. If missing any one of below might cause index out of range exception in BA failure.

  1. Private IP address
  2. Region where the cluster gets deployed.


s3://<bucket-name>/ <your private IP> us-east-1
replied 3 months ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
replied 3 months ago

Thanks for the update

replied 2 months ago