.aws/credencialへの設定
terraform-roleにはAdministratorAccessをつける
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[switch] aws_access_key_id = <key> aws_secret_access_key = <secret> [switch-dev] source_profile = switch role_arn = arn:aws:iam::xxxxxxxxxxx:role/Console-switched-role [switch-terraform-asuumerole] source_profile =switch-dev role_arn = arn:aws:iam::xxxxxxxxxxx:role/terraform-role region =ap-northeast-1 output =json |
terraformコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
terraform { required_version = "= 1.0.9" required_providers { aws = { source = "hashicorp/aws" version = "= 3.69" } } } provider "aws" { region = "ap-northeast-1" profile = "switch-terraform-asuumerole" } resource "aws_vpc" "main" { cidr_block = "10.0.0.0/16" tags = { Name = "terraform-test" } } |