Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify Dockerrun.aws.json for AWS using Terraform

I am attempting to host a Docker application with AWS via Elastic Beanstalk. When going through manual creation of an environment I am given the option to run a sample application in the environment, upload my own, or pull an application off of s3. By uploading a Dockerrun.aws.json file with all the necessary configuration the environment is able to pull and run my Docker image.

Now I am using Terraform to programmatically create and configure these environments. However, upon creation they all run the sample application, which in turn causes problems when I attempt to manually upload the Dockerrun file to the environment.

What is the proper way to include the Dockerrun information in the Terraform configuration so my application can deploy without a hitch?

like image 986
tVoss42 Avatar asked Jun 19 '17 15:06

tVoss42


People also ask

What is Dockerrun AWS JSON file?

A Dockerrun. aws. json file is an Elastic Beanstalk–specific JSON file that describes how to deploy a set of Docker containers as an Elastic Beanstalk application. You can use a Dockerrun.

What is Elastic Beanstalk used for?

AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Java, . NET, PHP, Node. js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS.

What is a Dockerfile AWS?

Docker lets you build, test, and deploy applications quickly Using Docker, you can quickly deploy and scale applications into any environment and know your code will run. Running Docker on AWS provides developers and admins a highly reliable, low-cost way to build, ship, and run distributed applications at any scale.


1 Answers

You should use an S3 bucket to store the Dockerrun.aws.json and set up a Beanstalk application version.

Something like:

resource "aws_elastic_beanstalk_application_version" "latest" {
  name        = "latest"
  application = "your_app"
  bucket      = "your_bucket"
  key         = "Dockerrun.aws.json"
}

Then add to your Beanstalk environment:

version_label = "${aws_elastic_beanstalk_application_version.latest.name}"

Of course, is better to use references instead of hardcoding names.

like image 72
charli Avatar answered Oct 27 '22 07:10

charli