Skip to content

Instantly share code, notes, and snippets.

@mominosin
Last active August 21, 2020 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mominosin/1695440edef34ee12dd323630ee64463 to your computer and use it in GitHub Desktop.
Save mominosin/1695440edef34ee12dd323630ee64463 to your computer and use it in GitHub Desktop.
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