Yet another Terraform ASG example, this one in pure TF
This is a demo of how to create a multi-tier ASG in pure Terraform.
The terraform/
directory contains the basic code, utilizing external modules,
to:
The config prints the ALB hostname and the security groups as outputs.
This example leans heavily on Terraform’s modules feature to demonstrate
the power of a repeatable configuration.
The modules we make use of are:
terraform_aws_vpc
terraform_aws_private_subnet
terraform_aws_alb
terraform_aws_asg
terraform_aws_security_group
All you need to use this repo is Terraform itself, and make
.
By default, the stack will deploy to us-west-2
. To deploy it, run
make infrastructure
Valid AWS credentials will need to be available in your credential chain, either
as environment variables (ie: AWS_ACCESS_KEY
, AWS_SECRET_ACCESS_KEY
andAWS_SESSION_TOKEN
), or your credentials in your ~/.aws
directory.
You can also control the build process through the following environment
variables:
AWS_DEFAULT_REGION
To control the region to deploy to (defaultus-west-2
).TF_CMD
To control the Terrafrom command (default apply
. Change this todestroy
to tear down the infrastructure).TF_DIR
To control the Terrafrom directory (default terraform
).This is an evolution of a lot of other work I’ve done on creating a deployment
pipeline pattern that heavily relies on Terraform. For my previous work, see:
Copyright 2016 Chris Marchesi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.