-
-
Save mominosin/1695440edef34ee12dd323630ee64463 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module vpc_a { | |
source = "terraform-aws-modules/vpc/aws" | |
} | |
module vpc_b { | |
source = "terraform-aws-modules/vpc/aws" | |
# マルチアカウントなので別のAWSアカウントを指定 | |
providers = { | |
aws = aws.b | |
} | |
} | |
# AからBへ繋がりたい | |
resource aws_vpc_peering_connection a_to_b { | |
peer_owner_id = module.vpc_b.vpc_id.vpc_owner_id | |
peer_vpc_id = module.vpc_b.vpc_id | |
vpc_id = module.vpc_a.vpc_id | |
auto_accept = false | |
} | |
# BからAへ繋がり許可 | |
resource aws_vpc_peering_connection_accepter b_to_a { | |
provider = aws.b | |
vpc_peering_connection_id = aws_vpc_peering_connection.a_to_b.id | |
auto_accept = true | |
} | |
# B側でリソースの設定変更する | |
resource aws_vpc_peering_connection_options b { | |
provider = aws.b | |
vpc_peering_connection_id = aws_vpc_peering_connection.a_to_b.id | |
accepter { | |
allow_remote_vpc_dns_resolution = true | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment