We want it to be as easy to use the New Relic Infrastructure (NRI) agent as possible. One way to make things easy? Automate them. This is especially helpful when you want to install the NRI agent on each of your Elastic Beanstalk applications. Though setting it up is easy, doing it repeatedly kind of takes the joy out of it. So, follow these basic instructions below to make it automatic.
Note: These instructions assume that you have someone on your team who maintains your AWS account. This person either manages usage or has delegated that responsibility to someone with the proper expertise. It is this ‘administrator’ what will make the best use of these instructions.
These instructions are based on these two AWS documentation links (as of 5/22/2017 and may change):
- Configuring the EC2 Instances in your Elastic Beanstalk Environment
- Creating a Custom Amazon Machine Image (AMI)
Here’s what you’re doing
In a nutshell, this is what you are going to do: Create a customized AMI that already has the NRI agent installed. Use that AMI with Elastic Beanstalk. When you create AWS Elastic Beanstalk applications, the underlining instances will automatically have the NRI agent installed.
High level Steps
- Find the default AMI name
- Launch an EC2 instance based on that AMI
- Install the NRI agent on your instance
- Create an Image from your instance
- Use customized AMI with Elastic Beanstalk
#1 Find the default AMI name
You’ll find the AMI name used when you setup an Elastic Beanstalk application.
- Go to Elastic Beanstalk in your AWS console
- Select ‘Get Started’ or ‘Create New Application’
- Give it an application name
- Select the Platform
- Select the 'Configure more options’ button
- Look for the ‘Instances’ box and select ‘Modify’
- Here you’ll see the AMI ID that will be used - make a note of it
- Cancel your way out of the steps. Note: you may need to delete the application
#2 Launch an EC2 instance based of that AMI
Use the AMI ID you noted in step #1 to launch an EC2 instance
- Go to EC2 in your AWS console
- ‘Launch Instance’
- Select ‘Community AMIs’
- Enter your noted step #1 AMI ID in the search field
- Select ‘Select’ and configure your instance using any company standards
- Launch it
#3 Install the NRI agent on your instance
Now that you have an EC2 instance up and running, log into it and install the NRI agent per the agent installation documentation for that operation system (OS).
#4 Create an Image from your instance
After you have customized your EC2 instance in step #3 and added the NRI agent (and done anything else you wanted) you’ll use this instance as your ‘golden’ image.
- Using the EC2 Dashboard, find your instance, select it, and select ’Stop’ from the ‘Actions’ menu
- After it is stopped, make sure it is selected in the EC2 Dashboard and select ‘Create Image’ from the Actions menu under Image
- After the image is finished, make a note of the new AMI name and you can now Terminate this instance as you’ll no longer need it
#5 Use customized AMI with Elastic Beanstalk
You are all set. When an Elastic Beanstalk application is setup, use your new AMI Image in the ‘Configure more options’ step. Note: This new AMI Image ID is one that you’ll want to publish to your internal AWS Elastic Beanstalk using teams so they may benefit.
How’d it go?
Let us know how this process worked for you and share any insights you gained in the process. We want to hear from you!