[Terraform]Terraform技巧:direnv; Backend, State, Workspace

[Terraform]Terraform技巧:direnv; Backend, State, Workspace

使用direnv来解决自动AWS Profile导入

  1. 先设置AWS profile
  2. 安装direnv
  3. 在所需目录下新加.envrc文件, 里面放比方:
export AWS_PROFILE=hzhu-nmdev
export TF_VAR_trendmicro_policy_id=3601
  1. 最后别忘了在.gitignore里添加**/.envrc,ignore所有.envrc。双*的作用是"to match directories anywhere in the repository."

References:
direnv
Automatically Switch AWS Profiles When Entering Your Git Repos
.gitignore

使用Backend同步Statefile

Workspaces

Terraform Enterprise: Understanding Workspaces and Modules
WX20200614-231545@2x

Subscribe to 隅

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe