This repository contains an infrastructure set-up with Terraform and AWS EB to setup CI/CD It contains:
- A Terraform setup for an AWS Elastic Beanstalk single docker container application.
- A deploy.sh bash script to deploy new versions to your AWS EB application
- An example Jenkinsfile
- A clean.sh script to clean generated stuff
- Terraform (here)
cd
to the infrastructure directory- Run
terraform init
- If you haven't already, run
aws configure --profile your-profile-name
to configure your AWS profile - Replace the variables in terraform.tfvars with your own
- Set your custom ENV variables like
export TF_VAR_env_custom_variable=test
or fill them in manually in the next step. - Run
terraform apply
- That's it! Elastic beanstalk is now live
cd
to the root of your project- Make sure you have Dockerized your application (there must be a Dockerfile in the root)
- Set AWS credentials as environment variables:
export AWS_ACCOUNT_ID=yourvalue export AWS_ACCESS_KEY_ID=yourvalue export AWS_SECRET_ACCESS_KEY=yourvalue
- Run
bash infrastructure/deploy.sh your-application-name playground eu-west-1 $(git rev-parse HEAD)
- Checkout how your app is running in the AWS Console :D
- In Jenkins, create a [pipelines Job] (https://jenkins.io/doc/book/pipeline/)
- Make sure it triggers on the branch you are pushing to
- Add the Jenkinsfile from the example and fill in the variables with yours.
- Push to the branch :D
terraform-aws-eb is released under the MIT License.