[Terraform]Terraform技巧:direnv; Backend, State, Workspace
使用direnv来解决自动AWS Profile导入
- 先设置AWS profile
- 安装direnv
- 在所需目录下新加.envrc文件, 里面放比方:
export AWS_PROFILE=hzhu-nmdev
export TF_VAR_trendmicro_policy_id=3601
- 最后别忘了在.gitignore里添加
**/.envrc
,ignore所有.envrc。双*的作用是"to match directories anywhere in the repository."
References:
direnv
Automatically Switch AWS Profiles When Entering Your Git Repos
.gitignore