Skip to content

Commit baf3e5b

Browse files
committed
chore: moving into its own file and adding the permission
1 parent 71d7ed5 commit baf3e5b

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

modules/shared/main.tf

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -111,34 +111,3 @@ resource "aws_network_acl_association" "nacl" {
111111
subnet_id = each.value.id
112112
}
113113

114-
## Provision a AWS RAM share, to distribute the subnets to the accounts
115-
resource "aws_ram_resource_share" "this" {
116-
name = local.ram_share_name
117-
allow_external_principals = false
118-
permission_arns = []
119-
tags = local.tags
120-
}
121-
122-
## Associate the subnets with the RAM share
123-
resource "aws_ram_resource_association" "this" {
124-
for_each = aws_subnet.subnets
125-
126-
resource_arn = each.value.arn
127-
resource_share_arn = aws_ram_resource_share.this.arn
128-
}
129-
130-
## Associate the principals with the RAM share
131-
resource "aws_ram_principal_association" "accounts" {
132-
for_each = toset(var.share.accounts)
133-
134-
principal = each.value
135-
resource_share_arn = aws_ram_resource_share.this.arn
136-
}
137-
138-
## Associate the principals with the RAM share
139-
resource "aws_ram_principal_association" "organizational_units" {
140-
for_each = toset(var.share.organizational_units)
141-
142-
principal = each.value
143-
resource_share_arn = aws_ram_resource_share.this.arn
144-
}

modules/shared/ram.tf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Related the RAM sharing
2+
3+
## Provision a AWS RAM share, to distribute the subnets to the accounts
4+
resource "aws_ram_resource_share" "this" {
5+
name = local.ram_share_name
6+
allow_external_principals = false
7+
permission_arns = ["arn:aws:ram::aws:permission/AWSRAMDefaultPermissionSubnet"]
8+
tags = local.tags
9+
}
10+
11+
## Associate the subnets with the RAM share
12+
resource "aws_ram_resource_association" "this" {
13+
for_each = aws_subnet.subnets
14+
15+
resource_arn = each.value.arn
16+
resource_share_arn = aws_ram_resource_share.this.arn
17+
}
18+
19+
## Associate the principals with the RAM share
20+
resource "aws_ram_principal_association" "accounts" {
21+
for_each = toset(var.share.accounts)
22+
23+
principal = each.value
24+
resource_share_arn = aws_ram_resource_share.this.arn
25+
}
26+
27+
## Associate the principals with the RAM share
28+
resource "aws_ram_principal_association" "organizational_units" {
29+
for_each = toset(var.share.organizational_units)
30+
31+
principal = each.value
32+
resource_share_arn = aws_ram_resource_share.this.arn
33+
}

0 commit comments

Comments
 (0)