0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

aws cliを使用する際にアカウントを使い分けている場合のterraform

Last updated at Posted at 2023-06-08

目的

・aws cliで以下のようなconfigファイルでアカウントを出し分けている場合の書き方を示しておく

~/.aws/config

[default]
region=
output=

[profile terraform]
region=ap-northeast-1
output=json

環境

・terraform: 1.2.9
・aws-cli: 2.11.25

方法

main.tf

provider "aws" {
  profile = var.aws_profile
  region  = "ap-northeast-1"
  default_tags {
    tags = {
      terraform-managed = "true"
    }
  }
}

valiables.tf

variable "aws_profile" { default = "terraform"}

後は通常通りコマンドをたたいていけば問題ないです。

$> terrafrom init
$> terraform plan
...
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?