{"id":360,"date":"2018-03-12T12:30:41","date_gmt":"2018-03-12T12:30:41","guid":{"rendered":"https:\/\/kevingoedecke.com\/?p=360"},"modified":"2018-08-25T00:09:10","modified_gmt":"2018-08-25T00:09:10","slug":"circleci-2-0-beanstalk-example-tutorial","status":"publish","type":"post","link":"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/","title":{"rendered":"CircleCI 2.0 Beanstalk Deployment example"},"content":{"rendered":"<p>Full code sample is now available on GitHub:<\/p>\n<p><a href=\"https:\/\/github.com\/kgoedecke\/circleci-beanstalk-example\">https:\/\/github.com\/kgoedecke\/circleci-beanstalk-example<\/a><\/p>\n<p>There are lot of tutorials out there that show how to create a pipeline to deploy apps on AWS Beanstalk using CircleCI but they were either for Version 1 or simply didn&#8217;t work because incorrectly set AWS credentials. That&#8217;s why I decided to write a tutorial which has all the steps needed to automatically deploy to AWS Elastic Beanstalk.<\/p>\n<p>Beanstalk is an amazing service to deploy and scale web apps and services written in Java,\u00a0.NET, PHP, Node.js, Python, Ruby, Go, and\u00a0Docker.<\/p>\n<p>I find it super convenient, with our setup I can simply push my code into a repository and CircleCI deploys to Beanstalk which then takes care of the provisioning of the underlying EC2 instances.<\/p>\n<p>In this tutorial we are going to deploy a small dummy NodeJS application using Github and CircleCI 2.0.<\/p>\n<h2>Overview of the tutorial:<\/h2>\n<p>1. Setup &#8211; We are going to create an AWS IAM user which will be used later with CircleCI to handle Beanstalk<br \/>\n2. Add Credentials to your local AWS EB CLI to spin up the Beanstalk environment<br \/>\n3. Beanstalk Environment &#8211; Deployment of the Beanstalk Environment<br \/>\n4. Connecting your Git Repository to CircleCI<br \/>\n5. Connect AWS to CircleCI using IAM Credentials<br \/>\n6. Create the CircleCI Config in the Repository<br \/>\n7. Happy Deploying<\/p>\n<h2><strong>Requirement:<\/strong><\/h2>\n<ul>\n<li>Python and PIP installed<\/li>\n<li>AWS Account with Admin Access to generate API credentials<\/li>\n<li>CircleCI account setup and linked to a GitHub or Bitbucket Repository<\/li>\n<\/ul>\n<h2><strong>Step 1: Setup IAM User<\/strong><\/h2>\n<p>Before starting to use CircleCI to deploy apps to Beanstalk, we need to generate API credentials that will then be used by CircleCI to execute the necessary commands. In order to generate the API credentials, sign into your\u00a0<a href=\"https:\/\/eu-central-1.signin.aws.amazon.com\"><strong>AWS Management Console<\/strong><\/a>\u00a0and go to \u201c<strong>Identity and Access Management \u2013 IAM<\/strong>\u201d:<\/p>\n<p>Then, click on \u201c<strong>Add user<\/strong>\u201d :<\/p>\n<p><a href=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Add-user-1st-page.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-351 size-large\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Add-user-1st-page-1024x471.png\" alt=\"circleci beanstalk \" width=\"1024\" height=\"471\" srcset=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Add-user-1st-page-1024x471.png 1024w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Add-user-1st-page-300x138.png 300w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Add-user-1st-page-768x353.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>Assign a\u00a0<strong>username<\/strong>\u00a0for the new account and select \u201c<strong>Programmatic access<\/strong>\u201c:<\/p>\n<p><a class=\"border-image\" href=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/IAM-user-programmatic-access.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-344 size-large\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/IAM-user-programmatic-access-1024x507.png\" alt=\"circleci beanstalk \" width=\"1024\" height=\"507\" srcset=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/IAM-user-programmatic-access-1024x507.png 1024w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/IAM-user-programmatic-access-300x149.png 300w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/IAM-user-programmatic-access-768x380.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>Add \u201c<strong>AmazonElasticBeanstalkFullAccess<\/strong>\u201d to user permissions list, this is whats needed for CircleCI to deploy to Beanstalk.<\/p>\n<p><a href=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Full-permission.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-347 size-large\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Full-permission-1024x507.png\" alt=\"circleci beanstalk \" width=\"1024\" height=\"507\" srcset=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Full-permission-1024x507.png 1024w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Full-permission-300x149.png 300w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Full-permission-768x380.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>Next, click on \u201c<strong>Review<\/strong>\u201d then &#8220;<strong>Create User&#8221;<\/strong>:<\/p>\n<p><a href=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Add-user.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-348 size-large\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Add-user-1024x434.png\" alt=\"circleci beanstalk \" width=\"1024\" height=\"434\" srcset=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Add-user-1024x434.png 1024w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Add-user-300x127.png 300w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Add-user-768x325.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>You&#8217;ll see your Access key ID and your Secret access Key. Both will be used later to trigger the Beanstalk commands from CircleCI.<\/p>\n<h2>Step 2: Add AWS Credentials locally<\/h2>\n<p>Using the AWS CLI locally we will spin up the Beanstalk environment that will be later used by CircleCI to deploy to. In order to use AWS CLI or EB CLI on your local computer we first need to create a credentials file (<span class=\"lang:default decode:true crayon-inline\">~\/.aws\/credentials<\/span>\u00a0) and store the IAM user credentials in it.<\/p>\n<p>Edit\u00a0<span class=\"lang:default decode:true crayon-inline\">~\/.aws\/credentials<\/span>\u00a0 and add the following content (replace YOUR_ACCESS_KEY_ID and YOUR_SECRET_ACCESS_KEY with the credentials generated in the previous step):<\/p>\n<pre class=\"\">[eb-cli]\r\naws_access_key_id=YOUR_ACCESS_KEY_ID\r\naws_secret_access_key=YOUR_SECRET_ACCESS_KEY<\/pre>\n<h2>Step 3:\u00a0 Install EB CLI<\/h2>\n<p>In this section, we are going to install\u00a0<strong><a href=\"https:\/\/aws.amazon.com\/cli\/\">AWS EB CLI<\/a>.<\/strong><\/p>\n<p>This step requires Python and pip installed locally. If you have everything ready execute the following command:<\/p>\n<pre class=\"\">pip install --upgrade --user awsebcli<\/pre>\n<p>After you&#8217;ve installed the\u00a0<strong>EB CLI<\/strong>, add the path to the executable file to your\u00a0<strong>PATH<\/strong>\u00a0variable.<\/p>\n<h2>Step 4: Create your Elastic Beanstalk environment<\/h2>\n<p>It&#8217;s time to create your Elastic Beanstalk Environment using the EB CLI from your local machine. Just navigate to your app directory (that needs to be deployed to Beanstalk later) and execute <span class=\"lang:default decode:true crayon-inline\">eb init<\/span>\u00a0 to initialize the directory as a Beanstalk application.<strong> NOTE: Alternatively you also use the AWS Management dashboard to create your Elastic Beanstalk environment.<\/strong><\/p>\n<p>Change into the directory of your app:<\/p>\n<pre class=\"lang:default decode:true\">cd ~\/workspace\/my-dummy-app\r\n<\/pre>\n<p>Initialize the app as a Beanstalk application:<\/p>\n<pre style=\"padding: 0; background: transparent; border: none;\" class=\"\">eb init --profile eb-cli\r\n\r\nSelect a default region\r\n1) us-east-1 : US East (N. Virginia)\r\n2) us-west-1 : US West (N. California)\r\n3) us-west-2 : US West (Oregon)\r\n4) eu-west-1 : EU (Ireland)\r\n5) eu-central-1 : EU (Frankfurt)\r\n6) ap-south-1 : Asia Pacific (Mumbai)\r\n7) ap-southeast-1 : Asia Pacific (Singapore)\r\n8) ap-southeast-2 : Asia Pacific (Sydney)\r\n9) ap-northeast-1 : Asia Pacific (Tokyo)\r\n10) ap-northeast-2 : Asia Pacific (Seoul)\r\n11) sa-east-1 : South America (Sao Paulo)\r\n12) cn-north-1 : China (Beijing)\r\n13) cn-northwest-1 : China (Ningxia)\r\n14) us-east-2 : US East (Ohio)\r\n15) ca-central-1 : Canada (Central)\r\n16) eu-west-2 : EU (London)\r\n17) eu-west-3 : EU (Paris)\r\n(default is 3): 5\r\n\r\nSelect an application to use\r\n1) server-backend\r\n2) [ Create new Application ]\r\n(default is 2): 2\r\n\r\nEnter Application Name\r\n(default is \"circleci-beanstalk-example\"):\r\nApplication circleci-beanstalk-example has been created.\r\n\r\nIt appears you are using Node.js. Is this correct?\r\n(Y\/n): Y\r\nNote: Elastic Beanstalk now supports AWS CodeCommit; a fully-managed source control service. To learn more, see Docs: https:\/\/aws.amazon.com\/codecommit\/\r\nDo you wish to continue with CodeCommit? (y\/N) (default is n):\r\nDo you want to set up SSH for your instances?\r\n(Y\/n): n<\/pre>\n<p>This will initialize your application and the environment, you&#8217;ll notice that the command has created a <span class=\"lang:default decode:true crayon-inline \">.elasticbeanstalk<\/span>\u00a0 folder in your application. Afterwards we can go ahead and actually spin up the enviroment.<\/p>\n<p>Execute the following command, make sure you use <span class=\"lang:default decode:true crayon-inline \">eb-cli<\/span>\u00a0 as the profile, because thats how we named our credentials in the <span class=\"lang:default decode:true crayon-inline \">~\/.aws\/credentials<\/span>\u00a0 file<\/p>\n<pre class=\"\">eb create --profile eb-cli\r\nEnter Environment Name\r\n(default is circleci-beanstalk-example-dev):\r\nEnter DNS CNAME prefix\r\n(default is circleci-beanstalk-example-dev):\r\n\r\nSelect a load balancer type\r\n1) classic\r\n2) application\r\n3) network\r\n(default is 1): 2\r\nWARNING: You have uncommitted changes.\r\nCreating application version archive \"app-6207-180303_000424\".\r\nUploading circleci-beanstalk-example\/app-6207-180303_000424.zip to S3. This may take a while.\r\nUpload Complete.\r\nEnvironment details for: circleci-beanstalk-example-dev\r\n Application name: circleci-beanstalk-example\r\n Region: eu-central-1\r\n Deployed Version: app-6207-180303_000424\r\n Environment ID: e-x4dhchqab3\r\n Platform: arn:aws:elasticbeanstalk:eu-central-1::platform\/Node.js running on 64bit Amazon Linux\/4.4.5\r\n Tier: WebServer-Standard-1.0\r\n CNAME: circleci-beanstalk-example-dev.eu-central-1.elasticbeanstalk.com\r\n Updated: 2018-03-02 23:04:27.933000+00:00\r\nPrinting Status:\r\nINFO: createEnvironment is starting.\r\nINFO: Using elasticbeanstalk-eu-central-1-216820535158 as Amazon S3 storage bucket for environment data.\r\nINFO: Created target group named: arn:aws:elasticloadbalancing:eu-central-1:216820535158:targetgroup\/awseb-AWSEB-1ESP9MVJF03WM\/c0c2e625e11502da\r\nINFO: Created security group named: sg-3017c85d\r\nINFO: Created security group named: awseb-e-x4dhchqab3-stack-AWSEBSecurityGroup-389LSAY1654Q\r\nINFO: Created Auto Scaling launch configuration named: awseb-e-x4dhchqab3-stack-AWSEBAutoScalingLaunchConfiguration-1363I5EH0W93A\r\n -- Events -- (safe to Ctrl+C)\r\nINFO: Created Auto Scaling group named: awseb-e-x4dhchqab3-stack-AWSEBAutoScalingGroup-618KCZ091L2D\r\nINFO: Waiting for EC2 instances to launch. This may take a few minutes.\r\nINFO: Created Auto Scaling group policy named: arn:aws:autoscaling:eu-central-1:216820535158:scalingPolicy:968245fa-08a9-434c-ae14-2683532a868b:autoScalingGroupName\/awseb-e-x4dhchqab3-stack-AWSEBAutoScalingGroup-618KCZ091L2D:policyName\/awseb-e-x4dhchqab3-stack-AWSEBAutoScalingScaleDownPolicy-J2G5Z2VU5CU2\r\nINFO: Created Auto Scaling group policy named: arn:aws:autoscaling:eu-central-1:216820535158:scalingPolicy:74b34e27-91b2-4654-ae4a-1adac1f12bd1:autoScalingGroupName\/awseb-e-x4dhchqab3-stack-AWSEBAutoScalingGroup-618KCZ091L2D:policyName\/awseb-e-x4dhchqab3-stack-AWSEBAutoScalingScaleUpPolicy-1084AE1QSLJED\r\nINFO: Created CloudWatch alarm named: awseb-e-x4dhchqab3-stack-AWSEBCloudwatchAlarmLow-1N62LDQ99LOQU\r\nINFO: Created CloudWatch alarm named: awseb-e-x4dhchqab3-stack-AWSEBCloudwatchAlarmHigh-1RKTU1TGKSTPM\r\nINFO: Created load balancer named: arn:aws:elasticloadbalancing:eu-central-1:216820535158:loadbalancer\/app\/awseb-AWSEB-1SMYH0Q88CKQP\/31bb253db6f8c427\r\nINFO: Created Load Balancer listener named: arn:aws:elasticloadbalancing:eu-central-1:216820535158:listener\/app\/awseb-AWSEB-1SMYH0Q88CKQP\/31bb253db6f8c427\/26fbd477342dee44\r\nINFO: Successfully launched environment: circleci-beanstalk-example-devssss<\/pre>\n<h2>Step 4: Connect Repo with CircleCI<\/h2>\n<p>Now that our application environment is up and running (please verify that it actually is using the AWS Management Dashboard), we can go ahead and connect CircleCI to Beanstalk.<\/p>\n<p>CircleCI needs a repository to pull the code from. Currently CircleCI supports GitHub and BitBucket. Go to\u00a0<a href=\"https:\/\/circleci.com\/signup\/\">https:\/\/circleci.com\/signup\/<\/a><\/p>\n<p>and Click on Signup with Github or Bitbucket. You should login into Github and Bitbucket before this.<\/p>\n<p><a href=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-09-at-12.54.06.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-367 size-large\" src=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-09-at-12.54.06-1024x336.png\" alt=\"circleci beanstalk \" width=\"1024\" height=\"336\" srcset=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-09-at-12.54.06-1024x336.png 1024w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-09-at-12.54.06-300x98.png 300w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-09-at-12.54.06-768x252.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<h2><strong>Step 5:<\/strong> Add IAM user Credentials in CircleCI<\/h2>\n<p>After you&#8217;ve linked your repository to your CircleCI account, head over to the <a href=\"https:\/\/circleci.com\/dashboard\">CircleCI Dashboard<\/a> and navigate into your project. Click on the settings icon of the repository that you want to setup.<\/p>\n<p><a href=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/circleci-beanstalk-settings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-378 size-large\" src=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/circleci-beanstalk-settings-1024x624.png\" alt=\"circleci beanstalk \" width=\"1024\" height=\"624\" srcset=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/circleci-beanstalk-settings-1024x624.png 1024w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/circleci-beanstalk-settings-300x183.png 300w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/circleci-beanstalk-settings-768x468.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>In the Settings section scroll down and click on &#8220;AWS Permissions&#8221; as shown in the screenshot below. Insert your access and secret key of the &#8220;circleci&#8221; programmatic user that we created previously using the AWS Dashboard.<\/p>\n<p><a href=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/AWS-permissions.png\"><img loading=\"lazy\" decoding=\"async\" class=\"Border=2 aligncenter wp-image-335 size-large\" src=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/AWS-permissions-1024x455.png\" alt=\"circleci beanstalk \" width=\"1024\" height=\"455\" srcset=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/AWS-permissions-1024x455.png 1024w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/AWS-permissions-300x133.png 300w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/AWS-permissions-768x342.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<h2><strong>Step 6: Create CircleCI config<\/strong><\/h2>\n<p>We are going to use <strong>CircleCI version 2.0 <\/strong>because<strong>\u00a0<\/strong><strong>CircleCI<\/strong> is officially discontinuing support for\u00a0<strong>CircleCI 1.0\u00a0<\/strong>builds after August 31st, 2018.<\/p>\n<p>Create\u00a0<span class=\"lang:default decode:true crayon-inline\">.circleci\/config.yml<\/span>\u00a0\u00a0inside the root directory of your application\u00a0and add it to your repository. CircleCI automatically sets two environment variables (<span class=\"lang:default decode:true crayon-inline\">$AWS_ACCESS_KEY_ID<\/span>\u00a0 and <span class=\"lang:default decode:true crayon-inline\">$AWS_SECRET_ACCESS_KEY<\/span>\u00a0). We will use those variables to configure the AWS EB CLI.<\/p>\n<pre class=\"lang:default decode:true \">version: 2\r\njobs:\r\n  deploy:\r\n    docker:\r\n      - image: circleci\/python:2.7\r\n    working_directory: ~\/repo\r\n    steps:\r\n      - checkout\r\n      - run:\r\n          name: Install awscli\r\n          command: |\r\n            sudo pip install awsebcli --upgrade\r\n      - run:\r\n          name: Create AWS credentials manually\r\n          command: |\r\n            mkdir ~\/.aws\r\n            touch ~\/.aws\/config\r\n            chmod 600 ~\/.aws\/config\r\n            echo \"[profile eb-cli]\" &gt; ~\/.aws\/config\r\n            echo \"aws_access_key_id=$AWS_ACCESS_KEY_ID\" &gt;&gt; ~\/.aws\/config\r\n            echo \"aws_secret_access_key=$AWS_SECRET_ACCESS_KEY\" &gt;&gt; ~\/.aws\/config\r\n      - run:\r\n          name: Deploy to EB if branch is Master\r\n          command: |\r\n            eb use circleci-beanstalk-example --profile eb-cli\r\n            eb deploy -v --staged --profile eb-cli\r\n\r\nworkflows:\r\n  version: 2\r\n  build-deploy:\r\n    jobs:\r\n      - deploy:\r\n          filters:\r\n            branches:\r\n              only:\r\n                - master\r\n                - develop<\/pre>\n<p>Let&#8217;s discuss the importance of the\u00a0<strong>CircleCI<\/strong> config and also look into the <span class=\"lang:default decode:true crayon-inline\">run<\/span>\u00a0 steps that we&#8217;ve configured.<\/p>\n<pre class=\"lang:default decode:true \">     - run:\r\n          name: Create AWS credentials manually\r\n          command: |\r\n            mkdir ~\/.aws\r\n            touch ~\/.aws\/config\r\n            chmod 600 ~\/.aws\/config\r\n            echo \"[profile eb-cli]\" &gt; ~\/.aws\/config\r\n            echo \"aws_access_key_id=$AWS_ACCESS_KEY_ID\" &gt;&gt; ~\/.aws\/config\r\n            echo \"aws_secret_access_key=$AWS_SECRET_ACCESS_KEY\" &gt;&gt; ~\/.aws\/config<\/pre>\n<p>In this step we are manually populate the AWS credentials from the environment variables that CircleCI sets. This is necessary because the AWS EB CLI is not able to use the environment variables directly.\u00a0Instead it needs them to be set in the config file (<span class=\"lang:default decode:true crayon-inline \">~\/.aws\/config<\/span>\u00a0).<\/p>\n<pre class=\"\">      - run:\r\n          name: Deploy to EB if branch is Master\r\n          command: |\r\n            eb use circleci-beanstalk-example --profile eb-cli\r\n            eb deploy -v --staged --profile eb-cli\r\n<\/pre>\n<p>The above step tells CircleCI\u00a0to use the environment named <span class=\"lang:default decode:true crayon-inline \">circleci-beanstalk-example<\/span>\u00a0with the credentials profile named <span class=\"lang:default decode:true crayon-inline\">eb-cli<\/span>, which we&#8217;ve defined in the config file. You might replace the name of the environment with the one of your application.<\/p>\n<p>After we&#8217;ve successfully created the\u00a0<strong>CircleCI<\/strong> config file, commit the file and push it to your repository.<\/p>\n<p>Go back to the CircleCI Dashboard and you should see your code building and deploying automatically to AWS ElasticBeanstalk.<\/p>\n<p><a href=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/CircleCI-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-350 size-large\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/CircleCI-build-1024x498.png\" alt=\"circleci beanstalk \" width=\"1024\" height=\"498\" srcset=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/CircleCI-build-1024x498.png 1024w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/CircleCI-build-300x146.png 300w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/CircleCI-build-768x373.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>Within the AWS Dashboard you should see the deployment process. After a little while the Health status should switch to &#8220;Ok&#8221;.<\/p>\n<p><a href=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-09-at-12.34.09.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-366 size-large\" src=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-09-at-12.34.09-1024x582.png\" alt=\"circleci beanstalk \" width=\"1024\" height=\"582\" srcset=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-09-at-12.34.09-1024x582.png 1024w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-09-at-12.34.09-300x171.png 300w, https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-09-at-12.34.09-768x437.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Every time code is pushed to the <span class=\"lang:default decode:true crayon-inline \">master<\/span>\u00a0 branch now CircleCI will deploy automatically to Beanstalk.<\/p>\n<p>If you run into any issues please feel free to comment below.<\/p>\n<p>In the next tutorial I&#8217;ll show you how to deploy to different environments for a staging and production environment using different branches (develop \/ master).<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Full code sample is now available on GitHub: https:\/\/github.com\/kgoedecke\/circleci-beanstalk-example There are lot of tutorials out there that show how to create a pipeline to deploy apps on AWS Beanstalk using CircleCI but they were either for Version 1 or simply didn&#8217;t work because incorrectly set AWS credentials. That&#8217;s why I decided to write a tutorial [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":386,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[25],"tags":[],"class_list":["post-360","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CircleCI 2.0 Beanstalk Deployment example - Kevin Goedecke<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CircleCI 2.0 Beanstalk Deployment example - Kevin Goedecke\" \/>\n<meta property=\"og:description\" content=\"Full code sample is now available on GitHub: https:\/\/github.com\/kgoedecke\/circleci-beanstalk-example There are lot of tutorials out there that show how to create a pipeline to deploy apps on AWS Beanstalk using CircleCI but they were either for Version 1 or simply didn&#8217;t work because incorrectly set AWS credentials. That&#8217;s why I decided to write a tutorial [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Kevin Goedecke\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-12T12:30:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-08-25T00:09:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/beanstalk-circleci-2-0-deployment@2x.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1800\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Kevin Goedecke\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kevin Goedecke\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/\",\"url\":\"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/\",\"name\":\"CircleCI 2.0 Beanstalk Deployment example - Kevin Goedecke\",\"isPartOf\":{\"@id\":\"https:\/\/kevingoedecke.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/beanstalk-circleci-2-0-deployment@2x.jpg\",\"datePublished\":\"2018-03-12T12:30:41+00:00\",\"dateModified\":\"2018-08-25T00:09:10+00:00\",\"author\":{\"@id\":\"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871\"},\"breadcrumb\":{\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/#primaryimage\",\"url\":\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/beanstalk-circleci-2-0-deployment@2x.jpg\",\"contentUrl\":\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/beanstalk-circleci-2-0-deployment@2x.jpg\",\"width\":1800,\"height\":900},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/kevingoedecke.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CircleCI 2.0 Beanstalk Deployment example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kevingoedecke.com\/#website\",\"url\":\"https:\/\/kevingoedecke.com\/\",\"name\":\"Kevin Goedecke\",\"description\":\"Founder. Entrepreneur.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kevingoedecke.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871\",\"name\":\"Kevin Goedecke\",\"url\":\"https:\/\/kevingoedecke.com\/blog\/author\/kgoedecke\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CircleCI 2.0 Beanstalk Deployment example - Kevin Goedecke","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"CircleCI 2.0 Beanstalk Deployment example - Kevin Goedecke","og_description":"Full code sample is now available on GitHub: https:\/\/github.com\/kgoedecke\/circleci-beanstalk-example There are lot of tutorials out there that show how to create a pipeline to deploy apps on AWS Beanstalk using CircleCI but they were either for Version 1 or simply didn&#8217;t work because incorrectly set AWS credentials. That&#8217;s why I decided to write a tutorial [&hellip;]","og_url":"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/","og_site_name":"Kevin Goedecke","article_published_time":"2018-03-12T12:30:41+00:00","article_modified_time":"2018-08-25T00:09:10+00:00","og_image":[{"width":1800,"height":900,"url":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/beanstalk-circleci-2-0-deployment@2x.jpg","type":"image\/jpeg"}],"author":"Kevin Goedecke","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kevin Goedecke","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/","url":"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/","name":"CircleCI 2.0 Beanstalk Deployment example - Kevin Goedecke","isPartOf":{"@id":"https:\/\/kevingoedecke.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/beanstalk-circleci-2-0-deployment@2x.jpg","datePublished":"2018-03-12T12:30:41+00:00","dateModified":"2018-08-25T00:09:10+00:00","author":{"@id":"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871"},"breadcrumb":{"@id":"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/#primaryimage","url":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/beanstalk-circleci-2-0-deployment@2x.jpg","contentUrl":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/beanstalk-circleci-2-0-deployment@2x.jpg","width":1800,"height":900},{"@type":"BreadcrumbList","@id":"https:\/\/kevingoedecke.com\/blog\/2018\/03\/12\/circleci-2-0-beanstalk-example-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kevingoedecke.com\/"},{"@type":"ListItem","position":2,"name":"CircleCI 2.0 Beanstalk Deployment example"}]},{"@type":"WebSite","@id":"https:\/\/kevingoedecke.com\/#website","url":"https:\/\/kevingoedecke.com\/","name":"Kevin Goedecke","description":"Founder. Entrepreneur.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kevingoedecke.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871","name":"Kevin Goedecke","url":"https:\/\/kevingoedecke.com\/blog\/author\/kgoedecke\/"}]}},"jetpack_featured_media_url":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2018\/03\/beanstalk-circleci-2-0-deployment@2x.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts\/360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/comments?post=360"}],"version-history":[{"count":17,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions"}],"predecessor-version":[{"id":439,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions\/439"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/media\/386"}],"wp:attachment":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/media?parent=360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/categories?post=360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/tags?post=360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}