Peering with same source and destination accounts
In the providers block, you may use any of the prescribed providers from the parent
module which is calling this module. In this example, I have used the same provider
which was from the acp_test_resources repo.
module "peering_example" {
source = "git::https://github.com/UKHomeOffice/acp-tf-peering?ref=v1.0.2"
providers = {
aws.source = aws.eu-west-2
aws.dest = aws.eu-west-2
}
auto_accept = true
vpc_source = {
vpc_id = "vpc-******"
account_id = "******"
name = "******"
vpc_cidr = "******"
}
vpc_dest = {
vpc_id = "vpc-******"
account_id = "******"
name = "******"
vpc_cidr = "******"
}
}
Peering between source and destination in different accounts
When you need to peer between VPCs in different accounts, you can
use the providers block to select different providers as stated in the parent
modules variables that is calling this module.
module "peer_acp_ci_to_acp_ops" {
source = "git::https://github.com/UKHomeOffice/acp-tf-peering.git?ref=v1.0.2"
providers = {
aws.source = aws.acp-ci
aws.dest = aws.acp-ops
}
vpc_source = {
name = "acp-ci"
account_id = data.terraform_remote_state.acp-ci.outputs.account_id
vpc_cidr = data.terraform_remote_state.acp-ci.outputs.vpc_cidr
vpc_id = data.terraform_remote_state.acp-ci.outputs.vpc_id
}
vpc_dest = {
name = "acp-ops"
account_id = var.acp_ops["account_id"]
vpc_cidr = var.acp_ops["vpc_cidr"]
vpc_id = var.acp_ops["vpc_id"]
}
source_tables = concat(values(data.terraform_remote_state.acp-ci.outputs.zone_gws), [data.terraform_remote_state.acp-ci.outputs.default_gw])
dest_tables = split(",", var.acp_ops["route_table_ids"])
}
No modules.
Name
Description
Type
Default
Required
auto_accept
Indicated we should attempt to accept on the peering side
bool
false
no
dest_tables
A list of routing tables id for the destination VPC
list(string)
[]
no
peer_region
The peering region if we are going across region
string
""
no
source_tables
A list of routing tables id for the source VPC
list(string)
[]
no
vpc_dest
A destination map containing the keys, vpc_id, account_id and name
map(string)
n/a
yes
vpc_source
A source map containing the keys, vpc_id, account_id and name
map(string)
n/a
yes
Name
Description
peering_id
The peering connection id for the connection
vpc_dest
The destination vpc id of the peering connection
vpc_source
The source vpc id of the peering connection