Skip to content

Instantly share code, notes, and snippets.

@mominosin

mominosin/peering_simple.tf Secret

Last active Aug 21, 2020
Embed
What would you like to do?
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.
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
You can’t perform that action at this time.