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 3 years have passed since last update.

terraformでAWSマルチリュージョンを管理する場合のサンプル

Posted at

やりかた

  • provideraliasを設定する
  • 各リソースでproviderを指定する
  • providerを2つ以上定義する場合、全リソースにどのproviderを利用するかを書かないといけないっぽい
  • CloudFront、TrustedAdvisorなどus-east-1リージョンでしか管理されていないリソースがいくつかあって、それを他リソースと混じったリポジトリで管理していく場合に必要っぽい

ソース

main.tf
provider "aws" {
  alias   = "us"
  version = "~> 2.9"
  region  = "us-east-1"
}

provider "aws" {
  alias   = "japan"
  version = "~> 2.9"
  region  = "ap-northeast-1"
}
vpc.tf
resource "aws_vpc" "japan" {
  provider   = aws.japan
  cidr_block = "172.16.0.0/16"
}

resource "aws_vpc" "us" {
  provider   = aws.us
  cidr_block = "192.168.0.0/24"
}

terraform plan

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_vpc.japan will be created
  + resource "aws_vpc" "japan" {
      + arn                              = (known after apply)
      + assign_generated_ipv6_cidr_block = false
      + cidr_block                       = "172.16.0.0/16"
      + default_network_acl_id           = (known after apply)
      + default_route_table_id           = (known after apply)
      + default_security_group_id        = (known after apply)
      + dhcp_options_id                  = (known after apply)
      + enable_classiclink               = (known after apply)
      + enable_classiclink_dns_support   = (known after apply)
      + enable_dns_hostnames             = (known after apply)
      + enable_dns_support               = true
      + id                               = (known after apply)
      + instance_tenancy                 = "default"
      + ipv6_association_id              = (known after apply)
      + ipv6_cidr_block                  = (known after apply)
      + main_route_table_id              = (known after apply)
      + owner_id                         = (known after apply)
    }

  # aws_vpc.us will be created
  + resource "aws_vpc" "us" {
      + arn                              = (known after apply)
      + assign_generated_ipv6_cidr_block = false
      + cidr_block                       = "192.168.0.0/24"
      + default_network_acl_id           = (known after apply)
      + default_route_table_id           = (known after apply)
      + default_security_group_id        = (known after apply)
      + dhcp_options_id                  = (known after apply)
      + enable_classiclink               = (known after apply)
      + enable_classiclink_dns_support   = (known after apply)
      + enable_dns_hostnames             = (known after apply)
      + enable_dns_support               = true
      + id                               = (known after apply)
      + instance_tenancy                 = "default"
      + ipv6_association_id              = (known after apply)
      + ipv6_cidr_block                  = (known after apply)
      + main_route_table_id              = (known after apply)
      + owner_id                         = (known after apply)
    }

Plan: 2 to add, 0 to change, 0 to destroy.

------------------------------------------------------------------------
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?