Skip to content

Commit af87a66

Browse files
authored
refactor: use local.ram_resource_share_enabled consistently (#65)
Replace direct references to var.ram_resource_share_enabled with the new local variable local.ram_resource_share_enabled throughout the code to ensure consistent behavior and improve maintainability.
1 parent 495fa8c commit af87a66

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ram.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
locals {
2+
ram_resource_share_enabled = module.this.enabled && var.ram_resource_share_enabled
3+
24
ram_principals_provided = var.ram_principal != null || length(var.ram_principals) > 0
3-
ram_principals = toset(var.ram_resource_share_enabled ? toset(
5+
ram_principals = toset(local.ram_resource_share_enabled ? toset(
46
local.ram_principals_provided ? concat(
57
var.ram_principal == null ? [] : [var.ram_principal],
68
var.ram_principals,
@@ -13,19 +15,19 @@ locals {
1315
# Resource Access Manager (RAM) share for the Transit Gateway
1416
# https://docs.aws.amazon.com/ram/latest/userguide/what-is.html
1517
resource "aws_ram_resource_share" "default" {
16-
count = var.ram_resource_share_enabled ? 1 : 0
18+
count = local.ram_resource_share_enabled ? 1 : 0
1719
name = module.this.id
1820
allow_external_principals = var.allow_external_principals
1921
tags = module.this.tags
2022
}
2123

2224
# Share the Transit Gateway with the Organization if RAM principal was not provided
2325
data "aws_organizations_organization" "default" {
24-
count = var.ram_resource_share_enabled && !local.ram_principals_provided ? 1 : 0
26+
count = local.ram_resource_share_enabled && !local.ram_principals_provided ? 1 : 0
2527
}
2628

2729
resource "aws_ram_resource_association" "default" {
28-
count = var.ram_resource_share_enabled ? 1 : 0
30+
count = local.ram_resource_share_enabled ? 1 : 0
2931
resource_arn = try(aws_ec2_transit_gateway.default[0].arn, "")
3032
resource_share_arn = try(aws_ram_resource_share.default[0].id, "")
3133
}

0 commit comments

Comments
 (0)