Skip to content

Commit

Permalink
AWS - IAM Organization Features Module (#118)
Browse files Browse the repository at this point in the history
* new module creation

* added org module for iam root management

* chore: terraform fmt and terraform-docs

* added header comment

* sets the provider requirements to 5.78.0

* chore: terraform fmt and terraform-docs

---------

Co-authored-by: zachreborn <[email protected]>
  • Loading branch information
zachreborn and zachreborn authored Jan 20, 2025
1 parent 0e8f64b commit 7ef14d2
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 4 deletions.
160 changes: 160 additions & 0 deletions modules/aws/iam/organizations_features/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<!-- Blank module readme template: Do a search and replace with your text editor for the following: `module_name`, `module_description` -->
<!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 -->

<a name="readme-top"></a>

<!-- PROJECT SHIELDS -->
<!--
*** I'm using markdown "reference style" links for readability.
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
*** See the bottom of this document for the declaration of the reference variables
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->

[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]

<!-- PROJECT LOGO -->
<br />
<div align="center">
<a href="https://github.com/zachreborn/terraform-modules">
<img src="/images/terraform_modules_logo.webp" alt="Logo" width="300" height="300">
</a>

<h3 align="center">IAM Organizations Features</h3>
<p align="center">
This module creates and manages IAM Organizations Features. This module enables centralized root management with an AWS Organization. This feature is a more secure and scalable way to manage your AWS environment's root accounts.
<br />
<a href="https://github.com/zachreborn/terraform-modules"><strong>Explore the docs »</strong></a>
<br />
<br />
<a href="https://zacharyhill.co">Zachary Hill</a>
·
<a href="https://github.com/zachreborn/terraform-modules/issues">Report Bug</a>
·
<a href="https://github.com/zachreborn/terraform-modules/issues">Request Feature</a>
</p>
</div>

<!-- TABLE OF CONTENTS -->
<details>
<summary>Table of Contents</summary>
<ol>
<li><a href="#usage">Usage</a></li>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#providers">Providers</a></li>
<li><a href="#modules">Modules</a></li>
<li><a href="#Resources">Resources</a></li>
<li><a href="#inputs">Inputs</a></li>
<li><a href="#outputs">Outputs</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#acknowledgments">Acknowledgments</a></li>
</ol>
</details>

<!-- USAGE EXAMPLES -->

## Usage

### Simple Example

Enables all features for the organization. These include centralized root management as well as temporary root access management.

```
module central_root_management {
source = "github.com/zachreborn/terraform-modules//modules/aws/iam/organizations_features"
}
```

_For more examples, please refer to the [Documentation](https://github.com/zachreborn/terraform-modules)_

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- terraform-docs output will be input automatically below-->
<!-- terraform-docs markdown table --output-file README.md --output-mode inject .-->
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.78.0 |

## Providers

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

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_iam_organizations_features.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_organizations_features) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_enabled_features"></a> [enabled\_features](#input\_enabled\_features) | A list of IAM organization features which will be enabled. Valid values are RootCredentialsManagement and RootSessions. | `list(string)` | <pre>[<br/> "RootCredentialsManagement",<br/> "RootSessions"<br/>]</pre> | no |

## Outputs

No outputs.
<!-- END_TF_DOCS -->

<!-- LICENSE -->

## License

Distributed under the MIT License. See `LICENSE.txt` for more information.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- CONTACT -->

## Contact

Zachary Hill - [![LinkedIn][linkedin-shield]][linkedin-url] - [email protected]

Project Link: [https://github.com/zachreborn/terraform-modules](https://github.com/zachreborn/terraform-modules)

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- ACKNOWLEDGMENTS -->

## Acknowledgments

- [Zachary Hill](https://zacharyhill.co)
- [Jake Jones](https://github.com/jakeasarus)

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->

[contributors-shield]: https://img.shields.io/github/contributors/zachreborn/terraform-modules.svg?style=for-the-badge
[contributors-url]: https://github.com/zachreborn/terraform-modules/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/zachreborn/terraform-modules.svg?style=for-the-badge
[forks-url]: https://github.com/zachreborn/terraform-modules/network/members
[stars-shield]: https://img.shields.io/github/stars/zachreborn/terraform-modules.svg?style=for-the-badge
[stars-url]: https://github.com/zachreborn/terraform-modules/stargazers
[issues-shield]: https://img.shields.io/github/issues/zachreborn/terraform-modules.svg?style=for-the-badge
[issues-url]: https://github.com/zachreborn/terraform-modules/issues
[license-shield]: https://img.shields.io/github/license/zachreborn/terraform-modules.svg?style=for-the-badge
[license-url]: https://github.com/zachreborn/terraform-modules/blob/master/LICENSE.txt
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://www.linkedin.com/in/zachary-hill-5524257a/
[product-screenshot]: /images/screenshot.webp
[Terraform.io]: https://img.shields.io/badge/Terraform-7B42BC?style=for-the-badge&logo=terraform
[Terraform-url]: https://terraform.io
29 changes: 29 additions & 0 deletions modules/aws/iam/organizations_features/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
###########################
# Provider Configuration
###########################
terraform {
required_version = ">= 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.78.0"
}
}
}

###########################
# Data Sources
###########################


###########################
# Locals
###########################

###########################
# Module Configuration
###########################

resource "aws_iam_organizations_features" "this" {
enabled_features = var.enabled_features
}
4 changes: 4 additions & 0 deletions modules/aws/iam/organizations_features/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
###########################
# Resource Outputs
###########################

16 changes: 16 additions & 0 deletions modules/aws/iam/organizations_features/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
###########################
# Resource Variables
###########################

###########################
# General Variables
###########################

variable "enabled_features" {
description = "A list of IAM organization features which will be enabled. Valid values are RootCredentialsManagement and RootSessions."
type = list(string)
default = [
"RootCredentialsManagement",
"RootSessions"
]
}
9 changes: 6 additions & 3 deletions modules/aws/organizations/organization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,19 @@ _For more examples, please refer to the [Documentation](https://github.com/zachr
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.78.0 |

## Providers

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

## Modules

No modules.
| Name | Source | Version |
|------|--------|---------|
| <a name="module_centralized_root"></a> [centralized\_root](#module\_centralized\_root) | ../../iam/organizations_features | n/a |

## Resources

Expand All @@ -115,6 +117,7 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_aws_service_access_principals"></a> [aws\_service\_access\_principals](#input\_aws\_service\_access\_principals) | (Optional) List of AWS service principal names for which you want to enable integration with your organization. This is typically in the form of a URL, such as service-abbreviation.amazonaws.com. Organization must have feature\_set set to ALL. For additional information, see the AWS Organizations User Guide. | `list(string)` | <pre>[<br/> "account.amazonaws.com",<br/> "aws-artifact-account-sync.amazonaws.com",<br/> "backup.amazonaws.com",<br/> "cloudtrail.amazonaws.com",<br/> "health.amazonaws.com",<br/> "sso.amazonaws.com"<br/>]</pre> | no |
| <a name="input_enabled_features"></a> [enabled\_features](#input\_enabled\_features) | A list of IAM organization features which will be enabled. Valid values are RootCredentialsManagement and RootSessions. | `list(string)` | <pre>[<br/> "RootCredentialsManagement",<br/> "RootSessions"<br/>]</pre> | no |
| <a name="input_enabled_policy_types"></a> [enabled\_policy\_types](#input\_enabled\_policy\_types) | (Optional) List of Organizations policy types to enable in the Organization Root. Organization must have feature\_set set to ALL. For additional information about valid policy types (e.g., AISERVICES\_OPT\_OUT\_POLICY, BACKUP\_POLICY, SERVICE\_CONTROL\_POLICY, and TAG\_POLICY), see the AWS Organizations API Reference. | `list(string)` | `null` | no |
| <a name="input_feature_set"></a> [feature\_set](#input\_feature\_set) | (Optional) Specify 'ALL' (default) or 'CONSOLIDATED\_BILLING'. | `string` | `"ALL"` | no |

Expand Down
11 changes: 10 additions & 1 deletion modules/aws/organizations/organization/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0.0"
version = ">= 5.78.0"
}
}
}
Expand All @@ -21,3 +21,12 @@ resource "aws_organizations_organization" "org" {
prevent_destroy = true
}
}

###########################################################
# Centralized Root Management
###########################################################
module "centralized_root" {
source = "../../iam/organizations_features"

enabled_features = var.enabled_features
}
9 changes: 9 additions & 0 deletions modules/aws/organizations/organization/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ variable "feature_set" {
}
}

variable "enabled_features" {
description = "A list of IAM organization features which will be enabled. Valid values are RootCredentialsManagement and RootSessions."
type = list(string)
default = [
"RootCredentialsManagement",
"RootSessions"
]
}

############################################################
# General Variables
############################################################

0 comments on commit 7ef14d2

Please sign in to comment.