How to configure a Linux instance for use as Elastic Image?
Asked by Alyson Whitaker:

Since my AWS account is in GovCloud, I am not able to utilize the provided default instances for reference of the setup. So I must use a custom AMI.

I built out a linux instance and add relevant packages in there. The next step is to configure the bamboo agent piece.

I am following this documentation: <https://confluence.atlassian.com/bamboo/creating-a-custom-elastic-image-289277146.html>

I get stuck at this part:

* **Environment Variables** --- you must set up the following environment variables on your local machine before creating a custom elastic image:
  * `EC2_HOME` --- set this to the path to the installed EC2 API Tools
  * `EC2_CERT` --- set this to the path to the certificate assigned to EC2 account
  * `EC2_PRIVATE_KEY` --- set this to the path to the private key assigned to your AWS account

Looking in my AWS account - I only see one top level cert (which I am unable to download) and not sure where to get the private key from either  

Then looking at this documentation: <https://confluence.atlassian.com/bamboo0701/creating-a-custom-elastic-image-linux-1031177907.html>

Where it tells you to create a profile.sh file:

    export JAVA_HOME=<path to JRE used to start the agent>export EC2_HOME=<location of your EC2 tools installation>export EC2_PRIVATE_KEY=/root/pk.pemexport EC2_CERT=/root/cert.pemexport PATH=/opt/bamboo-elastic-agent/bin:$EC2_HOME/bin:$JAVA_HOME/bin:$M2_HOME/bin:$MAVEN_HOME/bin:$ANT_HOME/bin:$PATH

I have a pem file I can use, just not sure about the cert piece.

Yes... I'm really confused. Any help/advice would be greatly appreciated!


Answers:
author: Eduardo Alvarenga
body: Hey [@Alyson Whitaker](/t5/user/viewprofilepage/user-id/4214699),

Thank you for using Atlassian Community!

Having AWS credentials inside your customised Bamboo elastic agent instance is totally optional. They are only necessary if you are willing to use [EBS](https://confluence.atlassian.com/display/BAMBOO/Configuring+elastic+instances+to+use+the+EBS) snapshots with your image.

If you wish to just set your custom image ready for any future EBS use implementation, just export the variables as in the documentation:  

```
export JAVA_HOME=<path to JRE used to start the agent>export EC2_HOME=<location of your EC2 tools installation>export EC2_PRIVATE_KEY=/root/pk.pemexport EC2_CERT=/root/cert.pemexport PATH=/opt/bamboo-elastic-agent/bin:$EC2_HOME/bin:$JAVA_HOME/bin:$M2_HOME/bin:$MAVEN_HOME/bin:$ANT_HOME/bin:$PATH
```

Then if you decide to use EBS in the future just make sure to specify both EC2 private key and certificates files in the Bamboo AWS configuration.

* <https://confluence.atlassian.com/display/BAMBOO/Configuring+Elastic+Bamboo#ConfiguringElasticBamboo-AWSsettings>

I'm afraid the private keys are only retrievable once, during its creation. You will need to check internally and understand if it was saved.

Regards,

Eduardo Alvarenga  
Atlassian Support APAC

comments: author: Alyson Whitaker
body: Hi Eduardo,

Thanks for the info.

Could you confirm if I need to install ec2-cli-tools or will installing the newer aws cli v2 suffice?

I have created an ec2 and created AMI from it. Attached that to elastic bamboo. the agent seems to start, but when trying to create an instance from it, it's stuck in pending. Checking the instance it creates, it's not pulling over the user data.


author: Eduardo Alvarenga
body: Hi [@Alyson Whitaker](/t5/user/viewprofilepage/user-id/4214699),

Some EBS instructions within Bamboo Elastic Agent are still attached to *ec2-\** commands. So it is recommended you have *ec2-cli-tools* for compatibility. They are:

* ec2-describe-volumes
* ec2-create-volume
* ec2-attach-volume
* ec2-detach-volume
* ec2-delete-volume
* ec2-modify-instance-attribute

You can also explore Bamboo scripts and make the required changes to them so they can use *aws* style commands directly.

Regards,

Eduardo Alvarenga  
Atlassian Support APAC


Tags: elastic

linux