forked from cloudposse/terraform-aws-transit-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ram.tf
25 lines (22 loc) · 1.17 KB
/
ram.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
# Resource Access Manager (RAM) share for the Transit Gateway
# https://docs.aws.amazon.com/ram/latest/userguide/what-is.html
resource "aws_ram_resource_share" "default" {
count = var.ram_resource_share_enabled ? 1 : 0
name = module.this.id
allow_external_principals = var.allow_external_principals
tags = module.this.tags
}
# Share the Transit Gateway with the Organization if RAM principal was not provided
data "aws_organizations_organization" "default" {
count = var.ram_resource_share_enabled && (var.ram_principal == null || var.ram_principal == "") ? 1 : 0
}
resource "aws_ram_resource_association" "default" {
count = var.ram_resource_share_enabled ? 1 : 0
resource_arn = try(aws_ec2_transit_gateway.default[0].arn, "")
resource_share_arn = try(aws_ram_resource_share.default[0].id, "")
}
resource "aws_ram_principal_association" "default" {
count = var.ram_resource_share_enabled ? 1 : 0
principal = try(coalesce(var.ram_principal, data.aws_organizations_organization.default[0].arn), "")
resource_share_arn = try(aws_ram_resource_share.default[0].id, "")
}