Skip to content

Commit 842b8f8

Browse files
committed
add story and implementation to blog
1 parent 28c7ac6 commit 842b8f8

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

content/blog/tag-strat-blog.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ weight: 1
1111

1212
Managing cloud resources efficiently in AWS requires a robust tagging strategy. Tags are key-value pairs attached to resources, providing crucial metadata for resource management, cost allocation, security, and automation. This blog will guide you through defining mandatory and discretionary tags and establishing detection and enforcement mechanisms to ensure compliance across your AWS environment.
1313

14+
## The Problem: Untracked Resources and Rising Costs
15+
16+
At Infraspec, we started noticing some major issues with how we were managing our AWS resources. We had several AWS accounts in use, but no tagging standards were enforced. This meant that anyone could create resources, and sometimes, these resources were left running long after they were needed.
17+
18+
As a result, our cloud costs were steadily increasing each month, and we had no clear way to track who was responsible for which resources. Without any tags, it was impossible to tie costs back to specific teams or projects, leaving us in the dark about where our budget was really going. This lack of accountability was causing both operational and financial headaches.
19+
20+
## The Solution: Enforcing a Tagging Policy
21+
22+
Realizing that we needed a way to get things under control, we started exploring how AWS tags could help. By enforcing a tagging policy across all our AWS accounts, we could ensure that every resource was labeled with essential information like the owner, team, and environment.
23+
24+
But we didn’t stop there. To make sure everyone followed the rules, we implemented Service Control Policies (SCPs) that would block the creation of any resources that didn’t have the necessary tags. This added a layer of enforcement that gave us confidence that our tagging strategy would actually be used.
25+
1426
## The Importance of Tagging
1527

1628
Tags are instrumental in achieving several goals within your AWS environment:
@@ -118,6 +130,78 @@ To ensure compliance with your tagging strategy, establish detection and enforce
118130
3. **Service Control Policies (SCPs)**: Use SCPs to prevent actions on resources without mandatory tags.
119131
4. **Compliance Audits**: Regularly audit resources to ensure they comply with the tagging policies. Automate this process where possible.
120132

133+
## Implementing Tagging Policies in AWS
134+
135+
### 1. **Enforcing Tagging Standards with AWS Organizations Tag Policies**
136+
137+
AWS Organizations allows you to create tag policies that enforce your tagging standards across all accounts in your organization. Here’s how to create a tag policy:
138+
139+
- **Step 1**: Navigate to AWS Organizations and select “Tag policies” from the sidebar.
140+
- **Step 2**: Click “Create policy” and define your tag rules. For example, you can enforce that all resources must have the `ManagedBy` tag.
141+
142+
```json
143+
{
144+
"tags": {
145+
"ManagedBy": {
146+
"tag_key": {
147+
"@@assign": "ManagedBy"
148+
},
149+
"tag_value": {
150+
"@@assign": [
151+
"Terraform",
152+
"Manual"
153+
]
154+
},
155+
"enforced_for": {
156+
"@@assign": [
157+
"ec2:instance",
158+
"ec2:vpc",
159+
"ec2:natgateway",
160+
"ec2:route-table",
161+
"ec2:internet-gateway"
162+
]
163+
}
164+
},
165+
}
166+
}
167+
```
168+
169+
- **Step 3**: Attach the policy to your organizational units (OUs) or accounts to enforce compliance.
170+
171+
### 2. **Using Service Control Policies (SCPs) to Block Non-Compliant Resources**
172+
173+
You can create SCPs in AWS Organizations to prevent the creation of resources without mandatory tags. Here’s an example policy:
174+
175+
```json
176+
{
177+
"Version": "2012-10-17",
178+
"Statement": [
179+
{
180+
"Sid": "DenyEC2CreationWithNoManagedByTag",
181+
"Effect": "Deny",
182+
"Action": [
183+
"ec2:RunInstances",
184+
"ec2:CreateVpc",
185+
"ec2:CreateNatGateway",
186+
"ec2:CreateRouteTable",
187+
"ec2:CreateInternetGateway"
188+
],
189+
"Resource": [
190+
"arn:aws:ec2:*:*:vpc/*",
191+
"arn:aws:ec2:*:*:natgateway/*",
192+
"arn:aws:ec2:*:*:route-table/*",
193+
"arn:aws:ec2:*:*:internet-gateway/*",
194+
"arn:aws:ec2:*:*:instance/*"
195+
],
196+
"Condition": {
197+
"Null": {
198+
"aws:RequestTag/ManagedBy": "true"
199+
}
200+
}
201+
}
202+
]
203+
}
204+
```
121205
## Tag Naming and Usage Conventions
122206

123207
To ensure consistency and avoid conflicts, adhere to the following conventions:
@@ -136,6 +220,10 @@ To ensure consistency and avoid conflicts, adhere to the following conventions:
136220
3. **Documentation**: Maintain comprehensive documentation of your tagging strategy and dictionary for reference.
137221
4. **Stakeholder Involvement**: Involve all relevant stakeholders in defining and reviewing the tagging strategy to ensure it meets organizational needs.
138222

223+
## The Impact: Accountability and Cost Control
224+
225+
Implementing this tagging strategy was a game-changer for us. We now had clear visibility into who was using what resources, and we could track our cloud costs with precision. This made it much easier to allocate expenses to the correct departments and projects, and we finally had the accountability we needed.
226+
139227
## Conclusion
140228

141229
A well-defined tagging strategy is essential for effective cloud resource management. By distinguishing between mandatory and discretionary tags and implementing robust enforcement mechanisms, you can achieve better visibility, cost control, and security in your AWS environment. Start by establishing a clear tagging dictionary and ensure compliance through automation and regular audits.

0 commit comments

Comments
 (0)