-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
32 lines (28 loc) · 1.13 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
resource "aws_ec2_transit_gateway" "tgw" {
amazon_side_asn = var.amazon_side_asn
description = var.description
tags = merge(var.tags, {
"Name" = var.name
})
}
resource "aws_ec2_transit_gateway_vpc_attachment" "tgw_attach" {
subnet_ids = var.subnet_ids
transit_gateway_id = aws_ec2_transit_gateway.tgw.id
vpc_id = var.vpc_id
}
resource "aws_ram_resource_share" "tgw_share" {
count = length(var.resource_share_accounts) > 0 ? 1 : 0
name = "${var.name}-tgw-share"
allow_external_principals = var.allow_external_principals
tags = var.tags
}
resource "aws_ram_principal_association" "tgw_ram_principal" {
count = length(var.resource_share_accounts)
principal = var.resource_share_accounts[count.index]
resource_share_arn = aws_ram_resource_share.tgw_share[0].arn
}
resource "aws_ram_resource_association" "tgw_ram_resource" {
count = length(var.resource_share_accounts) > 0 ? 1 : 0
resource_arn = aws_ec2_transit_gateway.tgw.arn
resource_share_arn = aws_ram_resource_share.tgw_share[0].arn
}