terraform-aws-vpc, 一个Terraform项目来启动 Amazon Web Services 虚拟 private 云

分享于 

5分钟阅读

GitHub

  繁體 雙語
A Terraform project to spin up an Amazon Web Services Virtual Private Cloud.
  • 源代码名称:terraform-aws-vpc
  • 源代码网址:http://www.github.com/hectcastro/terraform-aws-vpc
  • terraform-aws-vpc源代码文档
  • terraform-aws-vpc源代码下载
  • Git URL:
    git://www.github.com/hectcastro/terraform-aws-vpc.git
    Git Clone代码到本地:
    git clone http://www.github.com/hectcastro/terraform-aws-vpc
    Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/hectcastro/terraform-aws-vpc
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
    terraform-aws-vpc

    这个项目的目标是使用 Terraform 轻松地启动一个 Amazon Web Services ( AWS )虚拟 private 云( VPC )。

    配置

    项目 root 包含一个名为 terraform.tfvars.example的文件。 将该文件重命名为 terraform.tfvars 并使用AWS凭据填充它:

    $ mv terraform.tfvars.example terraform.tfvars
    $ vim terraform.tfvars

    项目 root 中也有一个 variables.tf。 它包含所有Terraform变量的列表。 这里设置了一些默认设置。 如果要覆盖其中的任何一个,请在 terraform.tfvars 中重写它们。

    用法

    所有与Terraform的交互都封装在 Makefile 中。 它包含规划。应用和销毁对AWS基础设施的更改的目标。

    计划

    计划阶段接受你的Terraform配置,并尝试向你提供一个计划,如果你应用了它,它将 它将执行计划沿着 terraform.tfplan 文件( 不可读的) 输出到 stdout

    $ make plan
    Refreshing Terraform state prior to plan...
    The Terraform execution plan has been generated and is shown below.
    Resources are shown in alphabetical order for quick scanning. Green resources
    will be created (or destroyed and then created if an existing resource
    exists), yellow resources are being changed in-place, and red resources
    will be destroyed.
    Your plan was also saved to the path below. Call the "apply" subcommand
    with this plan file and Terraform will exactly execute this execution
    plan.
    Path: terraform.tfplan

    应用

    应用阶段只是执行Terraform执行计划并尝试执行它。 它将进程沿着 terraform.tfstate 文件( 不可读的) 输出到 stdout

    $ make apply
    aws_vpc.default: Creating...
     cidr_block: "" =>"10.0.0.0/16"aws_vpc.default: Creation completeApply complete! Resources: 1 added, 0 changed, 0 destroyed.
    The state of your infrastructure has been saved to the path
    below. This state is required to modify and destroy your
    infrastructure, so keep it safe. To inspect the complete state
    use the `terraform show` command.
    State path: terraform.tfstate

    销毁

    破坏阶段发生在两个步骤中。 首先,Terraform生成一个销毁执行计划,然后应用它。 它将执行计划沿着新的terraform.tfplan 文件输出到 stdout。 然后,它尝试应用销毁执行计划。

    $ make destroy
    Refreshing Terraform state prior to plan...
    aws_vpc.default: Refreshing state... (ID: vpc-20bf1d45)
    The Terraform execution plan has been generated and is shown below.
    Resources are shown in alphabetical order for quick scanning. Green resources
    will be created (or destroyed and then created if an existing resource
    exists), yellow resources are being changed in-place, and red resources
    will be destroyed.
    Your plan was also saved to the path below. Call the "apply" subcommand
    with this plan file and Terraform will exactly execute this execution
    plan.
    Path: terraform.tfplan
    - aws_vpc.default
    aws_vpc.default: Destroying...
    aws_vpc.default: Destruction completeApply complete! Resources: 0 added, 0 changed, 1 destroyed.

    注意 Note: 由于删除弹性 IP ( EIP )的问题在从NAT实例解除绑定之前,通常需要多次运行该步骤。 在失败完成销毁阶段后再次运行 make destroy


    proj    亚马逊  Virtual  SPI  私有  
    相关文章