Skip to content

Commit

Permalink
CCL-1026 added tag policy
Browse files Browse the repository at this point in the history
  • Loading branch information
mynampatinaveen committed Nov 13, 2024
1 parent 3fd0789 commit 88b92c4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
23 changes: 23 additions & 0 deletions modules/aws/tag_policy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# AWS Organizations Tag Policy

This Terraform module creates and attaches an AWS Organizations TAG Policy. The policy allows you to specify which resources to be tagged of for your AWS Organization or specific AWS accounts.

## Resources

- `aws_organizations_policy`: Creates the tag policy.
- `aws_organizations_policy_attachment`: Attaches the tag policy to specified AWS Organization Units (OUs) or AWS accounts.

## Variables

### `policy_name`

- **Description**: The name of the Tag policy.
- **Type**: `string`
- **Default**: `"TagPolicy"`

### `policy_description`

- **Description**: The description of the Tag policy.
- **Type**: `string`
- **Default**: `"This Tag Policy will apply tags to resources"`

9 changes: 9 additions & 0 deletions modules/aws/tag_policy/enforce_mandatory_tag_values.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tags": {
"CostCentre": {
"tag_key": {
"@@assign": "CostCentre"
}
}
}
}
15 changes: 15 additions & 0 deletions modules/aws/tag_policy/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "aws_organizations_policy" "mandatory_tag_policy" {
name = var.policy_name
description = var.policy_description
type = "TAG_POLICY"
content = file(
"./enforce_mandatory_tag_values.template",
)
}


resource "aws_organizations_policy_attachment" "mandatory_tags" {
policy_id = aws_organizations_policy.mandatory_tag_policy.id
target_id = aws_organizations_organization.mandatory_tag_policy.roots[0].id
}

13 changes: 13 additions & 0 deletions modules/aws/tag_policy/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
variable "policy_name" {
description = "The name of the tag policy"
type = string
default = "TagPolicy"
}

variable "policy_description" {
description = "The description of the tag policy"
type = string
default = "Policy to add tags to resources"
}


0 comments on commit 88b92c4

Please sign in to comment.