Option 1:
--associate-public-ip-address command option with the as-create-launch-config command
Option 2:
Allocate an Elastic IP then adding a startup script in the Create Launch Configuration -> Configure Details -> Advanced Details -> User data:
--------------------------------------
#!/bin/bash
# configure AWS
aws configure set aws_access_key_id $accessKey
aws configure set aws_secret_access_key $secretAccessKey
aws configure set region {MY_REGION}
# associate Elastic IP
INSTANCE_ID=$(curl -s
ALLOCATION_ID={MY_EIP_ALLOC_ID}
aws ec2 associate-address --instance-id $INSTANCE_ID --allocation-id $ALLOCATION_ID --allow-reassociation
----------------------------------------
Example (SMTP01)
--------------------------------------
#!/bin/bash
# configure AWS
aws configure set aws_access_key_id $accessKey
aws configure set aws_secret_access_key $secretAccessKey
aws configure set region us-west-1b
# associate Elastic IP
INSTANCE_ID=$(curl -s
ALLOCATION_ID=i-80b45e42
aws ec2 associate-address --instance-id $INSTANCE_ID --allocation-id $ALLOCATION_ID --allow-reassociation
----------------------------------------
Categories: