.aws/credencialへの設定
terraform-roleにはAdministratorAccessをつける

[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コード

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"
  }
}

<スポンサーリンク>

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)