Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Relic Solution: AWS Elastic Beanstalk and the Golden Image

ec2
aws
infrastructure
elasticbeanstalk
rfb

#1

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):

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

  1. Find the default AMI name
  2. Launch an EC2 instance based on that AMI
  3. Install the NRI agent on your instance
  4. Create an Image from your instance
  5. 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 :seedling: 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 :rocket:

#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!


#2

Are you aware that AWS only recommends using a custom AMI if you are using ebextensions to customize your environment which take a long time to bootstrap your instance. Additionally using a custom AMI limits AWS’s ability to support your environment if there are issues, custom AMIs invariably cuase issues when there are changes to the Beanstalk service. Installing the New Relic infrastructure agent via an ebextension is fairly trivial and does not need the custom ami approach. I would recommend that you utilise your partnership and work with the AWS Elastic Beanstalk team to build an ebextension based on best practice from both sides which accomplishes the infrastructure installation tasks, then publish this to your github repo for the community to maintain.


#3

Thanks for the feedback. We actually did (most of) that. You’ll find the documentation for that here: Install the Infrastructure agent on AWS Elastic Beanstalk