Skip to content

Commit 2512bd2

Browse files
committed
feat: adds submodule to create organizations policy
1 parent 41b872c commit 2512bd2

File tree

6 files changed

+118
-0
lines changed

6 files changed

+118
-0
lines changed

modules/policy/.header.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Terraform AWS Organizations Policy Module
2+
3+
A Terraform module for creating and managing AWS Organizations Policy.

modules/policy/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Terraform AWS Organizations Policy Module
2+
3+
A Terraform module for creating and managing AWS Organizations Policy.
4+
5+
## Requirements
6+
7+
| Name | Version |
8+
|------|---------|
9+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.4.6 |
10+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.65.0 |
11+
12+
## Providers
13+
14+
| Name | Version |
15+
|------|---------|
16+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.65.0 |
17+
18+
## Modules
19+
20+
No modules.
21+
22+
## Resources
23+
24+
| Name | Type |
25+
|------|------|
26+
| [aws_organizations_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/organizations_policy) | resource |
27+
28+
## Inputs
29+
30+
| Name | Description | Type | Default | Required |
31+
|------|-------------|------|---------|:--------:|
32+
| <a name="input_content"></a> [content](#input\_content) | (Required) The policy content to add to the new policy. | `any` | n/a | yes |
33+
| <a name="input_description"></a> [description](#input\_description) | (Optional) A description to assign to the policy. | `string` | `null` | no |
34+
| <a name="input_name"></a> [name](#input\_name) | (Required) The friendly name to assign to the policy. | `string` | n/a | yes |
35+
| <a name="input_skip_destroy"></a> [skip\_destroy](#input\_skip\_destroy) | (Optional) If set to true, destroy will not delete the policy and instead just remove the resource from state. | `bool` | `false` | no |
36+
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) Key-value map of resource tags. | `map(string)` | `{}` | no |
37+
| <a name="input_type"></a> [type](#input\_type) | (Optional) The type of policy to create. | `string` | `"SERVICE_CONTROL_POLICY"` | no |
38+
39+
## Outputs
40+
41+
| Name | Description |
42+
|------|-------------|
43+
| <a name="output_aws_organizations_policy_arn"></a> [aws\_organizations\_policy\_arn](#output\_aws\_organizations\_policy\_arn) | Amazon Resource Name (ARN) of the policy. |
44+
| <a name="output_aws_organizations_policy_id"></a> [aws\_organizations\_policy\_id](#output\_aws\_organizations\_policy\_id) | The unique identifier (ID) of the policy. |
45+
| <a name="output_aws_organizations_policy_tags_all"></a> [aws\_organizations\_policy\_tags\_all](#output\_aws\_organizations\_policy\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block. |

modules/policy/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "aws_organizations_policy" "this" {
2+
content = var.content
3+
name = var.name
4+
description = var.description
5+
skip_destroy = var.skip_destroy
6+
type = var.type
7+
tags = var.tags
8+
}

modules/policy/outputs.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
output "aws_organizations_policy_id" {
2+
description = "The unique identifier (ID) of the policy."
3+
value = aws_organizations_policy.this.id
4+
}
5+
6+
output "aws_organizations_policy_arn" {
7+
description = "Amazon Resource Name (ARN) of the policy."
8+
value = aws_organizations_policy.this.arn
9+
}
10+
11+
output "aws_organizations_policy_tags_all" {
12+
description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block."
13+
value = aws_organizations_policy.this.tags_all
14+
}

modules/policy/variables.tf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
variable "content" {
2+
description = "(Required) The policy content to add to the new policy."
3+
type = any
4+
}
5+
6+
variable "name" {
7+
description = "(Required) The friendly name to assign to the policy."
8+
type = string
9+
}
10+
11+
variable "description" {
12+
description = "(Optional) A description to assign to the policy."
13+
type = string
14+
default = null
15+
}
16+
17+
variable "skip_destroy" {
18+
description = "(Optional) If set to true, destroy will not delete the policy and instead just remove the resource from state."
19+
type = bool
20+
default = false
21+
}
22+
23+
variable "type" {
24+
description = "(Optional) The type of policy to create."
25+
type = string
26+
default = "SERVICE_CONTROL_POLICY"
27+
28+
validation {
29+
condition = contains(["AISERVICES_OPT_OUT_POLICY", "BACKUP_POLICY", "SERVICE_CONTROL_POLICY", "TAG_POLICY"], var.type)
30+
error_message = "The 'type' variable must be one of: AISERVICES_OPT_OUT_POLICY, BACKUP_POLICY, SERVICE_CONTROL_POLICY, TAG_POLICY."
31+
}
32+
}
33+
34+
variable "tags" {
35+
description = "(Optional) Key-value map of resource tags."
36+
type = map(string)
37+
default = {}
38+
}

modules/policy/versions.tf

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)