Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Sergey Morkovkin October 28, 2012

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

1 vote
Answer accepted
LucasA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2012

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

0 votes
Matthew Sullivan June 4, 2014

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.

0 votes
Matthew Sullivan June 3, 2014

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
TAGS
AUG Leaders

Atlassian Community Events