Created
September 28, 2016 13:23
-
-
Save seventhskye/a9da24ad87f8cd4ecb4dbd2c0e2918ab to your computer and use it in GitHub Desktop.
Script to update an EC2 instance with an elastic IP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import boto3 | |
import requests | |
def main(argv): | |
instance_id = requests.get('http://169.254.169.254/latest/meta-data/instance-id').text | |
allocation_id = argv[1] | |
client = boto3.client('ec2') | |
response = client.associate_address(InstanceId=instance_id,AllocationId=allocation_id) | |
if __name__ == "__main__": | |
main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment