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

added group membership in identity center #56

Open
wants to merge 1 commit 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
174 changes: 174 additions & 0 deletions modules/aws/identity_center/group_membership/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<!-- 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">Identity Center User</h3>
<p align="center">
This module creates one or more users in AWS Identity Center (formerly AWS SSO). These users are then attached to groups in order to provide access to AWS accounts or applications.
<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
This example creates users managed by terraform. Note, we recommend using an IAM platform like AWS SSO, Microsoft Entra ID, or Okta as your IDP to manage groups and users automatically.
```
module "users" {
source = "github.com/zachreborn/terraform-modules//modules/aws/identity_center/user"

users = {
"Zachary Hill" = {
display_name = "Zachary Hill"
given_name = "Zachary"
family_name = "Hill"
user_name = "[email protected]"
email = "[email protected]"
email_is_primary = true
email_type = "work"
}
}
}
```

_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) | >= 4.0.0 |

## Providers

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

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_identitystore_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/identitystore_user) | resource |
| [aws_ssoadmin_instances.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssoadmin_instances) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_users"></a> [users](#input\_users) | (Required) The list of users to create. | <pre>map(object({<br> display_name = string # (Required) The friendly name to identify the user.<br> given_name = string # (Required) The given name of the user.<br> family_name = string # (Required) The family name of the user.<br> user_name = string # (Required) The username of the user.<br><br> honorific_prefix = optional(string) # (Optional) The honorific prefix of the user.<br> honorific_suffix = optional(string) # (Optional) The honorific suffix of the user.<br> middle_name = optional(string) # (Optional) The middle name of the user.<br> nickname = optional(string) # (Optional) The nickname of the user.<br><br> email = optional(string) # (Optional) The email address of the user.<br> email_is_primary = optional(bool) # (Optional) Indicates whether the email address is the primary email address of the user.<br> email_type = optional(string) # (Optional) The type of the email address of the user.<br> phone_number = optional(string) # (Optional) The phone number of the user.<br> phone_number_is_primary = optional(bool) # (Optional) Indicates whether the phone number is the primary phone number of the user.<br> phone_number_type = optional(string) # (Optional) The type of the phone number of the user.<br><br> preferred_language = optional(string) # (Optional) The user's preferred language.<br> timezone = optional(string) # (Optional) The user's time zone.<br> title = optional(string) # (Optional) The user's title.<br> user_type = optional(string) # (Optional) The type of the user.<br> }))</pre> | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_user_ids"></a> [user\_ids](#output\_user\_ids) | The IDs of the users in the identity store |
<!-- 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
37 changes: 37 additions & 0 deletions modules/aws/identity_center/group_membership/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
###########################
# Provider Configuration
###########################
terraform {
required_version = ">= 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0.0"
}
}
}

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

data "aws_ssoadmin_instances" "this" {}

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

locals {
identity_store_id = tolist(data.aws_ssoadmin_instances.this.identity_store_ids)[0]
}

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

resource "aws_identitystore_group_membership" "this" {
for_each = {for user_name, user_id in var.users : user_name => user_id}
identity_store_id = local.identity_store_id
group_id = var.group_id
member_id = each.value
}
4 changes: 4 additions & 0 deletions modules/aws/identity_center/group_membership/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "group_memberships" {
description = "List of AWS Identity Store group memberships created."
value = aws_identitystore_group_membership.this[*].id
}
9 changes: 9 additions & 0 deletions modules/aws/identity_center/group_membership/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "group_id" {
description = "(Required) The identifier for a group in the Identity Store."
type = string
}

variable "users" {
description = "(Required) A map of user names to their respective IDs."
type = map(string)
}