This folder contains an example of how define infrastructure-as-code using Terraform. The
Terraform templates in this folder show how to use the Terraform module defined in the rails-module
folder to take the AMI created in the packer-example folder
, deploy it on an EC2 instance, and run
the Ruby on Rails app within the AMI.
Note: these Terraform templates create real resources in your AWS account. The resources are part of the AWS Free Tier, but if you've used up all your credits, they may cost you money.
- Install Terraform.
- Open
vars.tf
, set the environment variables specified at the top of the file, and fill in any other variables that don't have adefault
. - Run
terraform get
. - Run
terraform plan
. - If the plan looks good, run
terraform apply
. - After the templates have been applied, Terraform will output a URL. Once the server is up and running (which can take 1-2 minutes), visit this URL to test the Rails app. You should see the text "Hello, World".
To clean up the resources created by these templates, just run terraform destroy
.