ec2-rotate-ip
v1.0.4
Published
A script that can be run periodically to change the public-facing IP on one or more EC2 instances in a region
Downloads
8
Readme
ec2-rotate-ip
A script that can be run periodically to change the public-facing IP on one or more EC2 instances in a region.
Pre-requisites
Ensure the following pre-requisites before running the script.
Instances
For any instance that should have its public IP rotated:
- Associate an Elastic IP with that instance.
- Create a tag on the Elastic IP:
- rotate=1 (key="rotate", value="1")
Environment
You will need Node.js installed and your environment configured with credentials to use the AWS Node.js SDK.
Required AWS permissions:
ec2:ReleaseAddress
ec2:DescribeAddresses
ec2:CreateTags
ec2:AssociateAddress
ec2:AllocateAddress
Example IAM policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ec2:ReleaseAddress",
"ec2:DescribeAddresses",
"ec2:CreateTags",
"ec2:AssociateAddress",
"ec2:AllocateAddress"
],
"Resource": "*"
}
]
}
Environment configuration instructions:
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html
Instructions
Run the following command whenever you want to rotate IPs:
AWS_REGION=us-east-1 npx ec2-rotate-ip