项目作者: vancluever

项目描述 :
Yet another Terraform ASG example, this one in pure TF
高级语言: HCL
项目地址: git://github.com/vancluever/terraform_autoscaling_vpc_example.git
创建时间: 2016-12-31T19:58:55Z
项目社区:https://github.com/vancluever/terraform_autoscaling_vpc_example

开源协议:Other

下载


Multi-Tier ASG Example in Pure Terraform

This is a demo of how to create a multi-tier ASG in pure Terraform.

What’s in It

The terraform/ directory contains the basic code, utilizing external modules,
to:

  • Create a VPC with public subnets.
  • Create private subnets, matching the public subnets’ availability zones, with
    NAT for outbound access.
  • ALB connected to the public subnets.
  • An ASG connected to the ALB. The instances in the launch configuration will
    find the latest hvm-ebs Amazon Linux instance, and then will bootstrap the
    instance with a test webpage based on pure user data. This setup does not
    require an AMI to be pre-built.

The config prints the ALB hostname and the security groups as outputs.

The Modules it Uses

This example leans heavily on Terraform’s modules feature to demonstrate
the power of a repeatable configuration.

The modules we make use of are:

Using this Repository

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

  1. 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 and
AWS_SESSION_TOKEN), or your credentials in your ~/.aws directory.

Environment variables

You can also control the build process through the following environment
variables:

  • AWS_DEFAULT_REGION To control the region to deploy to (default
    us-west-2).
  • TF_CMD To control the Terrafrom command (default apply. Change this to
    destroy to tear down the infrastructure).
  • TF_DIR To control the Terrafrom directory (default terraform).

More on these Patterns

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:

Author and License

  1. Copyright 2016 Chris Marchesi
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.