次の buildspec.yml を使用して、codebuild で terraform deploy を実行します。terraform は、codebuild ロールによって提供される IAM 権限を取得していないようです。テラフォームのリモート状態 (状態ファイルは s3 に保存されます) を使用しています。テラフォームが状態ファイルを含む S3 バケットに接続しようとすると、テラフォームprovider
を構成するように求められます。
Downloading modules (if any)...
Get: file:///tmp/src486521661/src/common/byu-aws-accounts-tf
Get: file:///tmp/src486521661/src/common/base-aws-account-
...
Error configuring the backend "s3": No valid credential sources found for AWS Provider.
buildspec.yml は次のとおりです。
version: 0.1
phases:
install:
commands:
- cd common && git clone https://eric.w.nord@gitlab.com/aws-account-tools/acs.git
- export TerraformVersion=0.9.3 && cd /tmp && curl -o terraform.zip https://releases.hashicorp.com/terraform/${TerraformVersion}/terraform_${TerraformVersion}_linux_amd64.zip && unzip terraform.zip && mv terraform /usr/bin
build:
commands:
- cd accounts/00/dev-stack-oit-byu && terraform init && terraform plan && echo terraform apply