terraformをdockerで使うメモ(AWS)
前提
以下のスクリプトをPATHの通ったどこかに置く(ここでは ~/bin/terraform
)
1 2 3 4 5 6 7 8 9
| #!/bin/bash -eu OWNER=$(echo "$(id -u ${USER}):$(id -g ${USER})")
docker run --rm -it \ -u ${OWNER} \ -w /workspace \ -v ${PWD}:/workspace \ -v ~/.aws:/.aws:ro \ hashicorp/terraform:light "${@}"
|
1 2 3 4
| $ chmod +x ~/bin/terraform
$ terraform version Terraform v0.12.26
|
初期設定
provider.tf
を作る
1 2 3 4 5
| provider "aws" { region = "ap-northeast-1" shared_credentials_file = "/.aws/credentials" profile = "(profile名を入力)" }
|
1 2 3 4 5 6 7
| $ terraform init
Initializing the backend...
* provider.aws: version = "~> 2.66"
Terraform has been successfully initialized!
|
あとはこちらの記事を参考に少し触ってみましたが問題なく動作していました