This is a Terraform tempate for deploying a docker application on Elastic Beanstalk.
Given a docker specification json for AWS, the root module is applied to create an AWS Elastc Beanstalk application version resource based on the json, which is zipped and stored on S3.
In the process, child modules provided by Cloud Posse, e.g. https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment, are called to create the EB application enviroment, VPC, subnets and other relevant resources.
To use or test the template, git clone the repo https://github.com/snpsuen/ElasticBeanstalk-Terraform-template01.git on a host where Terraform and AWS CLI are installed.
1. Edit Dockerrun.aws.json in the base directory by specifying what docker image to deploy on EB.
2. zip ebdemo01_node-app01.zip Dockerrun.aws.json
3. aws s3 cp ebdemo01_node-app01.zip s3://ebdem01.applicationversion.bucket/elasticbeanstalk/ebdemo01_node-app01.zip
4. cd terraform, set variables where necessary via terraform.tfvars as well as variables.tf for the root or child modules.
5. Return to the repo base directory and run the three terraform commands below in order:
5.1 terraform init terraform
5.2 terraform plan terraform
5.3 terraform apply terraform
Finally, after provisioning all the EB and AWS resources related to the application, run the the AWS CLI command to deploy the desirable application version onto EB.
aws --region
--- Sunny Suen