Skip to content

Commit 63939f4

Browse files
authored
Merge pull request #11 from arunlalp/gitlab
[TEC-69] Update tag-policy module to enforce specific values
2 parents d157a67 + 9f8b0e9 commit 63939f4

File tree

5 files changed

+31
-79
lines changed

5 files changed

+31
-79
lines changed

environments/dev/tag-policy/main.tf

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,12 @@ module "tag-policy" {
99
policy_type = var.policy_type
1010
target_id = var.target_id
1111

12-
name_tag_key = var.name_tag_key
13-
name_enforce_for_values = var.name_enforce_for_values
14-
15-
environment_tag_key = var.environment_tag_key
16-
environment_enforce_for_values = var.environment_enforce_for_values
17-
18-
owner_tag_key = var.owner_tag_key
19-
owner_tag_value = var.owner_tag_value
20-
owner_enforce_for_values = var.owner_enforce_for_values
21-
22-
costcenter_tag_key = var.costcenter_tag_key
23-
costcenter_tag_value = var.costcenter_tag_value
24-
costcenter_enforce_for_values = var.costcenter_enforce_for_values
25-
26-
application_tag_key = var.application_tag_key
27-
application_enforce_for_values = var.application_enforce_for_values
12+
name_tag_key = var.name_tag_key
13+
environment_tag_key = var.environment_tag_key
14+
owner_tag_key = var.owner_tag_key
15+
owner_tag_value = var.owner_tag_value
16+
costcenter_tag_key = var.costcenter_tag_key
17+
costcenter_tag_value = var.costcenter_tag_value
18+
application_tag_key = var.application_tag_key
19+
enforce_for_values = var.enforce_for_values
2820
}

environments/dev/tag-policy/variables.tf

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,11 @@ variable "name_tag_key" {
2323
description = "The tag key for the 'Name' tag."
2424
}
2525

26-
variable "name_enforce_for_values" {
27-
type = list(string)
28-
description = "A list of tag values to enforce for the 'Name' tag."
29-
}
30-
3126
variable "environment_tag_key" {
3227
type = string
3328
description = "The tag key for the 'Environment' tag."
3429
}
3530

36-
variable "environment_enforce_for_values" {
37-
type = list(string)
38-
description = "A list of tag values to enforce for the 'Environment' tag."
39-
}
40-
4131
variable "owner_tag_key" {
4232
type = string
4333
description = "The tag key for the 'Owner' tag."
@@ -48,11 +38,6 @@ variable "owner_tag_value" {
4838
description = "A list of valid tag values for the 'Owner' tag."
4939
}
5040

51-
variable "owner_enforce_for_values" {
52-
type = list(string)
53-
description = "A list of tag values to enforce for the 'Owner' tag."
54-
}
55-
5641
variable "costcenter_tag_key" {
5742
type = string
5843
description = "The tag key for the 'CostCenter' tag."
@@ -63,17 +48,12 @@ variable "costcenter_tag_value" {
6348
description = "A list of valid tag values for the 'CostCenter' tag."
6449
}
6550

66-
variable "costcenter_enforce_for_values" {
67-
type = list(string)
68-
description = "A list of tag values to enforce for the 'CostCenter' tag."
69-
}
70-
7151
variable "application_tag_key" {
7252
type = string
7353
description = "The tag key for the 'Application' tag."
7454
}
7555

76-
variable "application_enforce_for_values" {
56+
variable "enforce_for_values" {
7757
type = list(string)
7858
description = "A list of tag values to enforce for the 'Application' tag."
7959
}

modules/tag-policy/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ resource "aws_organizations_policy" "tag_policy" {
1212
"tags" = {
1313
"Name" = {
1414
"tag_key" = { "@@assign" = var.name_tag_key },
15-
"enforced_for" = { "@@assign" = var.name_enforce_for_values }
15+
"enforced_for" = { "@@assign" = var.enforce_for_values }
1616
},
1717
"Environment" = {
1818
"tag_key" = { "@@assign" = var.environment_tag_key },
19-
"enforced_for" = { "@@assign" = var.environment_enforce_for_values }
19+
"enforced_for" = { "@@assign" = var.enforce_for_values }
2020
},
2121
"Owner" = {
2222
"tag_key" = { "@@assign" = var.owner_tag_key },
2323
"tag_value" = { "@@assign" = var.owner_tag_value },
24-
"enforced_for" = { "@@assign" = var.owner_enforce_for_values }
24+
"enforced_for" = { "@@assign" = var.enforce_for_values }
2525
},
2626
"CostCenter" = {
2727
"tag_key" = { "@@assign" = var.costcenter_tag_key },
2828
"tag_value" = { "@@assign" = var.costcenter_tag_value },
29-
"enforced_for" = { "@@assign" = var.costcenter_enforce_for_values }
29+
"enforced_for" = { "@@assign" = var.enforce_for_values }
3030
},
3131
"Application" = {
3232
"tag_key" = { "@@assign" = var.application_tag_key },
33-
"enforced_for" = { "@@assign" = var.application_enforce_for_values }
33+
"enforced_for" = { "@@assign" = var.enforce_for_values }
3434
}
3535
}
3636
})

modules/tag-policy/variables.tf

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,11 @@ variable "name_tag_key" {
2323
description = "The tag key for the 'Name' tag."
2424
}
2525

26-
variable "name_enforce_for_values" {
27-
type = list(string)
28-
description = "A list of tag values to enforce for the 'Name' tag."
29-
}
30-
3126
variable "environment_tag_key" {
3227
type = string
3328
description = "The tag key for the 'Environment' tag."
3429
}
3530

36-
variable "environment_enforce_for_values" {
37-
type = list(string)
38-
description = "A list of tag values to enforce for the 'Environment' tag."
39-
}
40-
4131
variable "owner_tag_key" {
4232
type = string
4333
description = "The tag key for the 'Owner' tag."
@@ -48,11 +38,6 @@ variable "owner_tag_value" {
4838
description = "A list of valid tag values for the 'Owner' tag."
4939
}
5040

51-
variable "owner_enforce_for_values" {
52-
type = list(string)
53-
description = "A list of tag values to enforce for the 'Owner' tag."
54-
}
55-
5641
variable "costcenter_tag_key" {
5742
type = string
5843
description = "The tag key for the 'CostCenter' tag."
@@ -63,17 +48,12 @@ variable "costcenter_tag_value" {
6348
description = "A list of valid tag values for the 'CostCenter' tag."
6449
}
6550

66-
variable "costcenter_enforce_for_values" {
67-
type = list(string)
68-
description = "A list of tag values to enforce for the 'CostCenter' tag."
69-
}
70-
7151
variable "application_tag_key" {
7252
type = string
7353
description = "The tag key for the 'Application' tag."
7454
}
7555

76-
variable "application_enforce_for_values" {
56+
variable "enforce_for_values" {
7757
type = list(string)
7858
description = "A list of tag values to enforce for the 'Application' tag."
7959
}

vars/dev/tag-policy.tfvars

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ policy_name = "Techiescamp"
44
policy_type = "TAG_POLICY"
55
target_id = "814200988517"
66

7-
name_tag_key = "Name"
8-
name_enforce_for_values = ["ec2:instance", "ec2:security-group"]
9-
10-
environment_tag_key = "Environment"
11-
environment_enforce_for_values = ["ec2:instance", "ec2:security-group"]
12-
13-
owner_tag_key = "Owner"
14-
owner_tag_value = ["techiescamp"]
15-
owner_enforce_for_values = ["ec2:instance", "ec2:security-group"]
16-
17-
costcenter_tag_key = "CostCenter"
18-
costcenter_tag_value = ["techiescamp-commerce"]
19-
costcenter_enforce_for_values = ["ec2:instance", "ec2:security-group"]
20-
21-
application_tag_key = "Application"
22-
application_enforce_for_values = ["ec2:instance", "ec2:security-group"]
7+
name_tag_key = "Name"
8+
environment_tag_key = "Environment"
9+
owner_tag_key = "Owner"
10+
owner_tag_value = ["techiescamp"]
11+
costcenter_tag_key = "CostCenter"
12+
costcenter_tag_value = ["techiescamp-commerce"]
13+
application_tag_key = "Application"
14+
enforce_for_values = ["dynamodb:*", "ec2:dhcp-options", "ec2:elastic-ip", "ec2:fpga-image", "ec2:instance",
15+
"ec2:internet-gateway", "ec2:launch-template", "ec2:natgateway", "ec2:network-acl",
16+
"ec2:network-interface", "ec2:route-table", "ec2:security-group", "ec2:snapshot",
17+
"ec2:subnet", "ec2:volume", "ec2:vpc", "ec2:vpc-endpoint", "ec2:vpc-endpoint-service",
18+
"ec2:vpc-peering-connection", "ec2:vpn-connection", "ec2:vpn-gateway", "elasticfilesystem:*",
19+
"elasticloadbalancing:*", "iam:instance-profile", "iam:mfa", "iam:policy", "kms:*",
20+
"lambda:*", "rds:cluster-pg", "rds:cluster-endpoint", "rds:es", "rds:og", "rds:pg", "rds:db-proxy",
21+
"rds:db-proxy-endpoint", "rds:ri", "rds:secgrp", "rds:subgrp", "rds:target-group", "resource-groups:*",
22+
"route53:hostedzone", "s3:bucket", "s3:bucket"]
2323

2424

0 commit comments

Comments
 (0)