Menu
AWS for DevOps
Getting Started Guide

Step 5: Set Up for AWS Elastic Beanstalk

In this step, you will you will create AWS resources that Elastic Beanstalk will use to deploy the source code to the deployment target (an Amazon EC2 instance running Amazon Linux).

If you want to deploy with AWS CodeDeploy, go to Step 4: AWS CodeDeploy Setup.

If you want to deploy with AWS OpsWorks, go to Step 6: AWS OpsWorks Setup.

To log in to and explore the deployment target, you will need an Amazon EC2 key pair. You can use the key pair you created or identified in Step 2.2: Create a Key Pair.

The following procedure uses an AWS CloudFormation template to create an Elastic Beanstalk application, environment, service role, and an IAM instance profile, and to launch an Amazon Linux instance. (To view the contents of the AWS CloudFormation template, see ElasticBeanstalkSetup.template.) To learn how to create these resources in other ways, such as with the AWS Management Console or the AWS Command Line Interface (AWS CLI), see the following topics in the AWS Elastic Beanstalk Developer Guide:

To create the Elastic Beanstalk resources

  1. Use the AWS CloudFormation console to create a stack in the US East (N. Virginia) region based on the following Amazon S3 template URL: https://s3.amazonaws.com/aws-for-devops/cfn-templates/ElasticBeanstalkSetup.template

    On the Specify Details page, the settings in the Parameters area are used to:

    • Create a new Elastic Beanstalk application and environment, a service role, and an IAM instance profile. The service role enables Elastic Beanstalk to interact with dependent AWS services on the user's behalf. The IAM instance profile enables associated Amazon EC2 instance to interact with dependent AWS services.

    • Associate the new service role and IAM instance profile with the new environment.

    • Launch into the environment an Amazon EC2 instance running Amazon Linux. This instance allows users to log in to it by using the SSH protocol and to access it by using the HTTP protocol. The new IAM instance profile is attached to the instance.

    To accept these default settings, type your Amazon EC2 key pair name (for example, the one you created in Step 2.2: Create a Key Pair) into InstanceKeyPair, and then go to step 2 of this procedure.

    Alternatively, you may want to experiment with these default settings by running this template multiple times to create Elastic Beanstalk, IAM, and Amazon EC2 resources for this walkthrough. For example, later on you may want to create additional Elastic Beanstalk applications, environments, or both.

    The following table shows which settings to choose in the Parameters area.

    I want to create a new Elastic Beanstalk application.

    Leave Application set to the default value of New. For ApplicationName, type the name of the new application.

    Note

    Set Application to Existing if you only want to create a new Elastic Beanstalk environment for an existing application. For ApplicationName, type the name of the existing application.

    I want to create a new IAM instance profile for the Amazon Linux instance that will be launched into the new Elastic Beanstalk environment.

    Leave InstanceProfile set to the default value of New.

    Note

    Set InstanceProfile to Existing if you already have an IAM instance profile you want to use. For InstanceProfileARN, type the Amazon Resource Name (ARN) of the existing IAM instance profile. The IAM instance profile must be compatible with Elastic Beanstalk. For more information, see Elastic Beanstalk Instance Profile in the AWS Elastic Beanstalk Developer Guide.

    I want to create a new Elastic Beanstalk service role for the new Elastic Beanstalk environment.

    Leave ServiceRole set to the default value of New.

    Note

    Set ServiceRole to Existing if you already have a service role you want to use. For ServiceRoleARN, type the ARN of the existing service role. The service role must be compatible with Elastic Beanstalk. For more information, see Elastic Beanstalk Service Role in the AWS Elastic Beanstalk Developer Guide.

  2. When CREATE_COMPLETE is displayed for Status for this stack and for the stack named awseb-e-random-ID-stack, you can view the resources created by the stacks. Otherwise, go to Step 7.2: Create and Run the Pipeline for AWS Elastic Beanstalk.

    Note

    This stack creates an additional AWS CloudFormation stack for the Elastic Beanstalk environment with a name similar to awseb-e-random-ID-stack. Do not modify the stack. When you delete this stack in Step 11.3: Clean Up Elastic Beanstalk, AWS CloudFormation will delete the additional stack, too.

To explore the Elastic Beanstalk resources created by the stack

  1. In the AWS CloudFormation console, choose the Resources tab for the stack.

  2. If you created a new application, for ElasticBeanstalkApplication, choose the Physical ID link.

  3. On the All Applications > environment name page, choose the name of the new environment.

To explore the IAM resources created by the stack

  1. In the AWS CloudFormation console, choose the Resources tab for the stack.

  2. If you created a new IAM instance profile, for ElasticBeanstalkInstanceProfileRole, choose the Physical ID link.

  3. If you created a new service role, for ElasticBeanstalkServiceRole, choose the Physical ID link.

  4. Go to Step 7.2: Create and Run the Pipeline for AWS Elastic Beanstalk.