Does Terraform support application deployment using ElasticBeanstalk?
I've tried to deploy Spring Boot app using
`aws_elastic_beanstalk_application`,
`aws_elastic_beanstalk_application_version`
`aws_elastic_beanstalk_environment`
directives, but noticed it creates Elastic Beanstalk application, application version and environment, but does not deploy actual .jar file. I have to use aws elasticbeanstalk update-environment command to make it work.
The current version of Terraform just creates the s3 bucket, uploads your source code and then creates the application version in the elastic beanstalk.
To Deploy the version, use AWS CLI:
aws elasticbeanstalk update-environment \
--application-name test-app \
--version-label latest \
--environment-name test-env
Related
We have a setup with different AWS accounts for each environment(dev, test, prod) and then a shared build account which has a AWS CodePipeline that deploys into each of these environment by assuming a role in dev, test, prod.
This works fine for our Serverless applications using a Codebuild script.
Can we do something similar for the Elastic Beanstalk application that uses the deploy action provider? Or what is the best approach for Elastic Beanstalk
We do this by using a CodeBuild job specified in each of the stage accounts (dev, test, prod) that uses the AWS CLI to deploy the CodePipeline artifact (available as CODEBUILD_SOURCE_VERSION in your build job's environment variables) to Elastic Beanstalk. We run this job as part of a CodePipeline in our shared build account.
These are the AWS CLI commands the CodeBuild deploy job runs:
aws elasticbeanstalk create-application-version --application-name ... --version-label ... --source-bundle S3Bucket="codepipeline-artifacts-us-east-1-123456789012",S3Key="application/deployable/XXXXXXX"
aws elasticbeanstalk update-environment --environment-name ... --version-label ...
You can specify a CodeBuild job from another account in CodePipeline using the strategy outlined here: https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-create-cross-account.html. It involves setting up cross-account access to the role_arn used for the CodeBuild deploy job and a customer managed KMS key for the pipeline (with a cross-account access policy).
One deficiency with this approach is that the CodeBuild deploy job will complete as soon as the deployment starts and not wait until the ElasticBeanstalk deployment succeeds or fails, as the native CodePipeline EB deploy action does. You should be able to call aws elasticbeanstalk describe-environments in a loop from the job to replicate this behavior, but I have not yet attempted this. (Sample script here: https://blog.cyplo.net/posts/2018/04/wait-for-beanstalk/)
I have found the solution to cross account deployment of application to elastic beanstalk in another aws account using aws cdk.
As aws cdk do not have deploy to elastic beanstalk action feature yet so we have to implement it manually by implementing IAction interface
You can find complete working CDK app in my git repo
https://github.com/dhirajkhodade/CDKDotNetWebAppEbPipeline
We ended up solving it this way using CodeBuild:
version: 0.2
phases:
install:
runtime-versions:
python: 3.8
commands:
- pip install awsebcli --upgrade
pre_build:
commands:
- CRED=`aws sts assume-role --role-arn $assume_role --role-session-name codebuild-deployment-$environment`
- export AWS_ACCESS_KEY_ID=`node -pe 'JSON.parse(process.argv[1]).Credentials.AccessKeyId' "$CRED"`
- export AWS_SECRET_ACCESS_KEY=`node -pe 'JSON.parse(process.argv[1]).Credentials.SecretAccessKey' "$CRED"`
- export AWS_SESSION_TOKEN=`node -pe 'JSON.parse(process.argv[1]).Credentials.SessionToken' "$CRED"`
- export AWS_EXPIRATION=`node -pe 'JSON.parse(process.argv[1]).Credentials.Expiration' "$CRED"`
- echo $(aws sts get-caller-identity)
build:
commands:
- eb --version
- eb init <project-name> --platform "Node.js running on 64bit Amazon Linux" --region $AWS_DEFAULT_REGION
- eb deploy
Using the aws-cli to assume the role we needed and then using eb-cli to do the actual deployment. Not sure if this is the best way, but it works. We are considering moving to another CI/CD tool which is more flexi
I was trying to install newest Bluemix container service with Kubenetes plug-in; however, I got below message. Followed by DOC - container service
ocmbpro:~ ochen$ bx plugin install container-service -r Bluemix
Looking up 'container-service' from repository 'Bluemix'...
FAILED
'Bluemix' does not exist as an available plug-in repo. Check the name and try again.
Error_msg
Has anyone met this issue ?
You can download the plugin binary directly here:
https://clis.ng.bluemix.net/ui/repository.html#bluemix-plugins
Then run bx plugin install ~/Downloads/my-plugin.
You could run this command to add Bluemix to your list of available repos:
bx plugin repo-add Bluemix https://plugins.ng.bluemix.net
After that, when you list your repos, it should be there:
$ bx plugin repos
Listing added plug-in repositories...
Repo Name URL
Bluemix https://plugins.ng.bluemix.net
Then you can list the plugins:
$ bx plugin repo-plugins
Getting plug-ins from all repositories...
Repository: Bluemix
Name Description Versions
active-deploy Bluemix CLI plugin for Active Deploy to help you update applications and containers with no downtime. Works for Cloud Foundry apps and for IBM Containers. 0.1.97, 0.1.105
auto-scaling Bluemix CLI plug-in for Auto-Scaling service 0.2.1, 0.2.2
vpn Bluemix CLI plug-in for IBM VPN service 1.5.0, 1.5.1, 1.5.2
private-network-peering pnp-plugin-description 0.1.1
IBM-Containers Plugin to operate IBM Containers service 1.0.0
container-registry Plugin for IBM Bluemix Container Registry. 0.1.104, 0.1.107
container-service IBM Bluemix Container Service for management of Kubernetes clusters 0.1.217
sdk-gen Plugin to generate SDKs from Open API specifications 0.1.1
dev IBM Bluemix CLI Developer Plug-in 0.0.5
Then you can install one:
bluemix plugin install plugin_name -r Bluemix
I am using Azure cli. I have created app by using azure cli command. azure site create $SITENAME --location $LOCATION --hostname $HOSTNAME -s $SUBSCRIPTIONID.
Now i want to connect it with my git account using Azure CLI.
If you use the new CLI 2.0 (https://github.com/Azure/azure-cli) you should be able to use the following command:
az appservice web source-control config-local-git -g {group} -n {webapp name}
git remote add azure https://<deploy_user_name>#MyApp.scm.azurewebsites.net/MyApp.git
If this doesn't work for your scenario, please post a feature request to our repo.
If you wish to customize continious deployment, I'm afraid there is no way to use Azure CLI in this case now.
Please use Azure web-portal to do it - details are here
You can also use Visual Studio Team Services and have the compile website, and then execute your ARM template, through release management to update environment.
Is it possible to setup a web hook to automatically deploy a new version of an application from a Docker Hub repository to Elastic Beanstalk?
I currently have the following setup:
Bitbucket Repo -----> Docker Hub -----> Elastic Beanstalk
When I push to the master branch on the git repository, it triggers a build on the Docker repository through a POST request. However, once the image is built, I have to manually deploy it on EB.
Docker Hub has the option for making a POST request whenever a build is successfully completed. Is there some API or URL that I could point Docker to call so that EB redeploys the application?
Note: Eventually I would like to include an automated testing server into this workflow.
AWS does not seem to have a HTTP API, but you can use the aws command-line tool to trigger the update: https://stackoverflow.com/a/41715702/5879759
I'm using the eb CLI tool to create my application and environments on Elastic Beanstalk, but finding that it's creating a Worker 1.0 tier.
Is there a way I can use .ebextensions or a script that runs on "eb start" that can upgrade the tier to v1.1?
When you run eb init, eb generates a file with name .elasticbeanstalk/config in your app source directory.
You can modify the tier version in this file.
You can change from EnvironmentTier=Worker::SQS/HTTP::1.0 to EnvironmentTier=Worker::SQS/HTTP::1.1 and when you launch an environment it will launch with worker tier 1.1.
Tier version cannot be modified via ebextensions.