How do we configure an Elastic Bamboo Image to auto-associate IP address?

Hello.

Just trying to auto-associate an IP to an elastic instance. What was done:

1. Configured to upload AWS private key and certificate to new instance.

2. In the startup script run the following command: ec2-associate-address -K /root/pk.pem -C /root/cert.pem -i $(curl -s http://169.254.169.254/latest/meta-data/instance-id) xx.xxx.xx.xxx

What's interesting is that this command works well from the terminal, but doesn't work on startup. I've also tried to invoke it from rc.local. Still no effect. Could you please suggest a workaround?

3 answers

1 accepted

Hello,

Put this script to run on bin/customise-extras.sh (https://confluence.atlassian.com/display/BAMBOO/Configuring+elastic+instances+to+use+the+EBS). This script runs after the system starts with root privileges.

Cheers,

Lucas Luma

Atlassian Support

I know this is a bit old but it has become easier to do now, and without EBS. AWS added the IAM User concept and priveleges, so you can configure a new user with just permissions to set the IP address.

Go to the Security Credentials and create a new user, download and keep the credentials. Attach a custom Security Policy with the following, which will restrict the permissions to associate the IP Address

{
  "Statement": [
    {
      "Action": [
        "ec2:AssociateAddress",
        "ec2:DisassociateAddress"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}


Then in Bamboo, edit the image to add this startup script:

export EC2_HOME=/opt/aws/apitools/ec2
export JAVA_HOME=/opt/jdk-6
/opt/aws/bin/ec2-associate-address -O [aws-access-key] -W [aws-secret-key] -i $(/usr/bin/curl -s http://169.254.169.254/latest/meta-data/instance-id) [eip]
sleep 30

Replacing the [aws-access-key] and [aws-secret-key] with that of the IAM user key, and the [eip] to be the Elastic IP. $(/usr/bin/curl -s http://169.254.169.254/latest/meta-data/instance-id) curls the AWS metadata and gets the latest instance ID. I had connection reset issues pretty consistently, and adding a the sleep 30 seemed to resolve this.

I know this is a bit old but it has become easier to do now, and without EBS. AWS added the IAM User concept and priveleges, so you can configure a new user with just permissions to set the IP address.

Go to the Security Credentials and create a new user, download and keep the credentials. Attach a custom Security Policy with the following, which will restrict the permissions to associate the IP Address

{
  "Statement": [
    {
      "Action": [
        "ec2:AssociateAddress",
        "ec2:DisassociateAddress"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}


Then in Bamboo, edit the image to add this startup script:

export EC2_HOME=/opt/aws/apitools/ec2
export JAVA_HOME=/opt/jdk-6
/opt/aws/bin/ec2-associate-address -O [aws-access-key] -W [aws-secret-key] -i $(/usr/bin/curl -s http://169.254.169.254/latest/meta-data/instance-id) [eip]
sleep 30

Replacing the [aws-access-key] and [aws-secret-key] with that of the IAM user key, and the [eip] to be the Elastic IP. $(/usr/bin/curl -s http://169.254.169.254/latest/meta-data/instance-id) curls the AWS metadata and gets the latest instance ID. I had connection reset issues pretty consistently, and adding a the sleep 30 seemed to resolve this.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Tuesday in Uncategorized

Friday fun: how many celebrates Midsummer holiday or is this a Swedish tradition only?

Any other country that celebrates Midsummer holiday (this friday 22 June)?  

44 views 3 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you