Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ou & account creation #4

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,3 @@ repos:
- "--args=--only=terraform_standard_module_structure"
- "--args=--only=terraform_workspace_remote"
- id: terraform_trivy
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
12 changes: 9 additions & 3 deletions modules/accounts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A Terraform module which configures your AWS Organization and creates AWS accoun

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.49.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5 |

## Resources

Expand All @@ -24,15 +24,21 @@ A Terraform module which configures your AWS Organization and creates AWS accoun
| [aws_account_alternate_contact.operations](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/account_alternate_contact) | resource |
| [aws_account_alternate_contact.security](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/account_alternate_contact) | resource |
| [aws_account_primary_contact.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/account_primary_contact) | resource |
| [aws_guardduty_detector.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/guardduty_detector) | resource |
| [aws_guardduty_organization_admin_account.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/guardduty_organization_admin_account) | resource |
| [aws_inspector2_delegated_admin_account.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/inspector2_delegated_admin_account) | resource |
| [aws_organizations_account.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/organizations_account) | resource |
| [aws_organizations_delegated_administrator.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/organizations_delegated_administrator) | resource |
| [aws_securityhub_organization_admin_account.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/securityhub_organization_admin_account) | resource |
| [aws_vpc_ipam_organization_admin_account.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_ipam_organization_admin_account) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_accounts"></a> [accounts](#input\_accounts) | List of AWS accounts to create | <pre>map(object({<br> email = string<br> close_on_deletion = optional(bool)<br> iam_user_access_to_billing = optional(bool)<br> delegated_administrator_services = list(string)<br> tags = optional(map(string))<br> parent_id = optional(string)<br> }))</pre> | n/a | yes |
| <a name="input_accounts"></a> [accounts](#input\_accounts) | List of AWS accounts to create | <pre>map(object({<br> email = string<br> close_on_deletion = optional(bool)<br> iam_user_access_to_billing = optional(string)<br> delegated_administrator_services = list(string)<br> tags = optional(map(string))<br> parent_id = optional(string)<br> }))</pre> | n/a | yes |
| <a name="input_contacts"></a> [contacts](#input\_contacts) | Primary and alternate contacts for the accounts | <pre>object({<br> primary_contact = object({<br> address_line_1 = string<br> address_line_2 = optional(string)<br> address_line_3 = optional(string)<br> city = string<br> company_name = optional(string)<br> country_code = string<br> district_or_county = optional(string)<br> full_name = string<br> phone_number = string<br> postal_code = string<br> state_or_region = optional(string)<br> website_url = optional(string)<br> })<br> operations_contact = object({<br> name = string<br> title = string<br> email_address = string<br> phone_number = optional(string)<br> })<br> billing_contact = object({<br> name = string<br> title = string<br> email_address = string<br> phone_number = optional(string)<br> })<br> security_contact = object({<br> name = string<br> title = string<br> email_address = string<br> phone_number = optional(string)<br> })<br> })</pre> | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to the resources | `map(string)` | n/a | yes |

## Outputs

Expand All @@ -48,4 +54,4 @@ Checkout our other :point\_right: [terraform modules](https://registry.terraform

## Copyright

Copyright © 2017-2023 [Blackbird Cloud](https://www.blackbird.cloud)
Copyright © 2017-2023 [Blackbird Cloud](https://www.blackbird.cloud)
2 changes: 1 addition & 1 deletion modules/accounts/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resource "aws_organizations_account" "default" {
name = each.key
email = each.value.email
close_on_deletion = try(each.value.close_on_deletion, null)
iam_user_access_to_billing = try(each.value.iam_user_access_to_billing, null)
iam_user_access_to_billing = each.value.iam_user_access_to_billing == null ? "ALLOW" : each.value.iam_user_access_to_billing
tags = merge(each.value.tags, var.tags)
parent_id = try(each.value.parent_id, null)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/accounts/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ variable "accounts" {
type = map(object({
email = string
close_on_deletion = optional(bool)
iam_user_access_to_billing = optional(bool)
iam_user_access_to_billing = optional(string)
delegated_administrator_services = list(string)
tags = optional(map(string))
parent_id = optional(string)
Expand Down
4 changes: 2 additions & 2 deletions modules/organizational-units/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A Terraform module which configures your AWS Organization and creates AWS accoun

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.49.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5 |

## Resources

Expand All @@ -27,7 +27,7 @@ A Terraform module which configures your AWS Organization and creates AWS accoun

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_organization_units"></a> [organization\_units](#input\_organization\_units) | List of organizational units to create | <pre>map(object(<br> {<br> name = string<br> parent_id = string<br> tags = optional(map(string))<br> }<br> ))</pre> | n/a | yes |
| <a name="input_organization_units"></a> [organization\_units](#input\_organization\_units) | List of organizational units to create | <pre>map(object(<br> {<br> parent_id = string<br> tags = optional(map(string))<br> }<br> ))</pre> | n/a | yes |

## Outputs

Expand Down
2 changes: 1 addition & 1 deletion modules/organizational-units/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "aws_organizations_organizational_unit" "default" {
for_each = var.organization_units

name = each.value.name
name = each.key
parent_id = each.value.parent_id
tags = each.value.tags
}
1 change: 0 additions & 1 deletion modules/organizational-units/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ variable "organization_units" {
description = "List of organizational units to create"
type = map(object(
{
name = string
parent_id = string
tags = optional(map(string))
}
Expand Down
Loading