Skip to content

Commit bdccb7b

Browse files
committed
feat: adds example for creating standard organizations policies
1 parent a1591bd commit bdccb7b

File tree

7 files changed

+182
-0
lines changed

7 files changed

+182
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
locals {
2+
aws_region = "ap-south-1"
3+
tag_policy_file_content = file("${path.module}/tag_policy.json")
4+
tag_policy_name = "STANDARD_TAG_POLICIES"
5+
tag_policy_description = "Recommend tag policies"
6+
tag_policy_type = "TAG_POLICY"
7+
default_tags = {}
8+
tag_policy_taget_id = "123456789098"
9+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module "tag_policy" {
2+
source = "../../modules/policy"
3+
content = local.tag_policy_file_content
4+
name = local.tag_policy_name
5+
description = local.tag_policy_description
6+
type = local.tag_policy_type
7+
tags = local.default_tags
8+
}
9+
10+
11+
module "attach_tag_policy" {
12+
source = "../../modules/policy_attachment"
13+
policy_id = module.tag_policy.aws_organizations_policy_id
14+
target_id = local.tag_policy_taget_id
15+
}

examples/create-standard-organization-policies/outputs.tf

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "aws" {
2+
region = local.aws_region
3+
}
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
{
2+
"tags": {
3+
"Owner": {
4+
"tag_key": {
5+
"@@assign": "Owner"
6+
},
7+
"enforced_for": {
8+
"@@assign": [
9+
"ec2:instance",
10+
"ec2:vpc",
11+
"ec2:subnet",
12+
"ec2:natgateway",
13+
"ec2:security-group",
14+
"ec2:route-table",
15+
"ec2:internet-gateway"
16+
]
17+
}
18+
},
19+
"Team": {
20+
"tag_key": {
21+
"@@assign": "Team"
22+
},
23+
"tag_value": {
24+
"@@assign": ["DevOps"]
25+
},
26+
"enforced_for": {
27+
"@@assign": ["ec2:instance"]
28+
}
29+
},
30+
"Environment": {
31+
"tag_key": {
32+
"@@assign": "Environment"
33+
},
34+
"tag_value": {
35+
"@@assign": ["Development", "Production", "Staging"]
36+
},
37+
"enforced_for": {
38+
"@@assign": [
39+
"ec2:instance",
40+
"ec2:vpc",
41+
"ec2:subnet",
42+
"ec2:natgateway",
43+
"ec2:security-group",
44+
"ec2:route-table",
45+
"ec2:internet-gateway"
46+
]
47+
}
48+
},
49+
"CostCenter": {
50+
"tag_key": {
51+
"@@assign": "CostCenter"
52+
},
53+
"tag_value": {
54+
"@@assign": ["General"]
55+
},
56+
"enforced_for": {
57+
"@@assign": [
58+
"ec2:instance",
59+
"ec2:vpc",
60+
"ec2:subnet",
61+
"ec2:natgateway",
62+
"ec2:security-group",
63+
"ec2:route-table",
64+
"ec2:internet-gateway"
65+
]
66+
}
67+
},
68+
"DataClassification": {
69+
"tag_key": {
70+
"@@assign": "DataClassification"
71+
},
72+
"tag_value": {
73+
"@@assign": ["Public", "Internal", "Confidential"]
74+
},
75+
"enforced_for": {
76+
"@@assign": [
77+
"ec2:instance",
78+
"ec2:vpc",
79+
"ec2:subnet",
80+
"ec2:natgateway",
81+
"ec2:security-group",
82+
"ec2:route-table",
83+
"ec2:internet-gateway"
84+
]
85+
}
86+
},
87+
"Service": {
88+
"tag_key": {
89+
"@@assign": "Service"
90+
},
91+
"tag_value": {
92+
"@@assign": ["Micro", "Monolithic"]
93+
},
94+
"enforced_for": {
95+
"@@assign": [
96+
"ec2:instance",
97+
"ec2:vpc",
98+
"ec2:subnet",
99+
"ec2:natgateway",
100+
"ec2:security-group",
101+
"ec2:route-table",
102+
"ec2:internet-gateway"
103+
]
104+
}
105+
},
106+
"ManagedBy": {
107+
"tag_key": {
108+
"@@assign": "ManagedBy"
109+
},
110+
"tag_value": {
111+
"@@assign": ["Terraform", "Manual"]
112+
},
113+
"enforced_for": {
114+
"@@assign": [
115+
"ec2:instance",
116+
"ec2:vpc",
117+
"ec2:subnet",
118+
"ec2:natgateway",
119+
"ec2:security-group",
120+
"ec2:route-table",
121+
"ec2:internet-gateway"
122+
]
123+
}
124+
},
125+
"Compliance": {
126+
"tag_key": {
127+
"@@assign": "Compliance"
128+
},
129+
"tag_value": {
130+
"@@assign": ["N/A", "NIST", "HIPAA", "GDPR"]
131+
},
132+
"enforced_for": {
133+
"@@assign": [
134+
"ec2:instance",
135+
"ec2:vpc",
136+
"ec2:subnet",
137+
"ec2:natgateway",
138+
"ec2:security-group",
139+
"ec2:route-table",
140+
"ec2:internet-gateway"
141+
]
142+
}
143+
}
144+
}
145+
}

examples/create-standard-organization-policies/variables.tf

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.4.6"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 4.65.0"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)