terraform之aws-provider入门

文章目录

  1. 1. terraform
    1. 1.1. Headfirst
      1. 1.1.1. aws prepare
      2. 1.1.2. try terraform first
    2. 1.2. Summary

terraform

Use Infrastructure as Code to provision and manage any cloud, infrastructure, or service
用于像代码一样使用基础设施,提供和管理任何云、基础设施或服务

Headfirst

aws prepare

  • account
    register free-trail account

  • install cli

    1
    2
    # install cli: aws
    pip3 install awscli --upgrade --user
  • credential configure
    Authenticating to AWS with the Credentials File
    备注:

  • credential
    官方建议使用IAM创建user的access key

    • 找到IAM,配置对应group,user,policy,并将policy attach到对应user或组
    • users下找到对应用户的security_credentials配置,创建 access key
  • profile
    默认是default,若需配置,须同~/.aws/config 中配置对应,否则无法执行

    #如下有default和user2两种profile配置
    [default]
    region = us-east-2
    output = json
    
    [profile user2]  
    region=us-east-1  
    output=text

    try terraform first

    terraform-get-started-with-first-sample

Summary

了解terraform管理基础设施的常用命令

  • terraform init 按配置初始化环境
  • terraform plan 查看将执行的计划
  • terraform apply 执行计划
  • terraform destroy 移除terraform管理的基础设施

后续用到的查询文档即可:

如有疑问,请文末留言交流或邮件:newbvirgil@gmail.com 本文链接 : https://newbmiao.github.io/2019/10/18/terraform-aws-provider-headfirst.html