Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}


Loading