Skip to content

Commit 08df483

Browse files
authored
Merge pull request #6 from speee/add-example
Add docs and example
2 parents 3a5b77a + cafcd45 commit 08df483

File tree

18 files changed

+398
-1
lines changed

18 files changed

+398
-1
lines changed

README.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,70 @@
22

33
Terraform module which creates AWS SSO assignments on AWS.
44

5+
## Usage
6+
```hcl
7+
module "account_assignments" {
8+
source = "speee/sso_assignments/aws"
9+
10+
instance_arn = "arn:aws:sso:::instance/ssoins-9999999999999999"
11+
identity_store_id = "d-9999999999"
12+
13+
organization_accounts = [
14+
{
15+
arn = "arn:aws:organizations::123456789012:account/o-xxxxxxxxxx/123456789012"
16+
17+
id = "123456789012"
18+
name = "account1"
19+
},
20+
{
21+
arn = "arn:aws:organizations::123456789012:account/o-xxxxxxxxxx/234567890123"
22+
23+
id = "234567890123"
24+
name = "account2"
25+
},
26+
]
27+
28+
assignments = {
29+
"account1" = {
30+
"groups" = {
31+
"SystemAdministrator" = [
32+
"AdministratorAccess",
33+
],
34+
"Engineer" = [
35+
"PowerUserAccess",
36+
],
37+
"Manager" = [
38+
"ReadOnlyAccess",
39+
],
40+
},
41+
"users" = {
42+
43+
"AdministratorAccess",
44+
],
45+
},
46+
},
47+
"account2" = {
48+
"users" = {
49+
50+
"AdministratorAccess",
51+
],
52+
53+
"ReadOnlyAccess",
54+
],
55+
},
56+
},
57+
}
58+
}
59+
```
60+
61+
## Examples
62+
- [All account assignments in a single module](https://github.com/speee/terraform-aws-sso-assignment/tree/master/examples/all-in-one)
63+
- [Account assignments per organization units](https://github.com/speee/terraform-aws-sso-assignment/tree/master/examples/module-per-organizations-unit)
64+
65+
## Notes
66+
1. This module does not create no resource other than `aws_ssoadmin_account_assignment` resource. Use resources or data sources directly to manage other resources like `aws_ssoadmin_permission_set`.
67+
68+
569
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
670
## Requirements
771

@@ -14,7 +78,7 @@ Terraform module which creates AWS SSO assignments on AWS.
1478

1579
| Name | Version |
1680
|------|---------|
17-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.52.0 |
81+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.24.0 |
1882

1983
## Modules
2084

examples/all-in-one/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# All account assignments in a single module
2+
3+
Define all account assignments in a single module.
4+
5+
## Usage
6+
7+
To run this example you need to execute:
8+
9+
```bash
10+
$ terraform init
11+
$ terraform plan
12+
$ terraform apply
13+
```
14+
15+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
16+
## Requirements
17+
18+
| Name | Version |
19+
|------|---------|
20+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.7 |
21+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >=3.24.0 |
22+
23+
## Providers
24+
25+
| Name | Version |
26+
|------|---------|
27+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.24.0 |
28+
29+
## Modules
30+
31+
| Name | Source | Version |
32+
|------|--------|---------|
33+
| <a name="module_all_assignments"></a> [all\_assignments](#module\_all\_assignments) | ../.. | n/a |
34+
35+
## Resources
36+
37+
| Name | Type |
38+
|------|------|
39+
| [aws_organizations_organization.organization](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/organizations_organization) | data source |
40+
| [aws_ssoadmin_instances.instances](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssoadmin_instances) | data source |
41+
42+
## Inputs
43+
44+
| Name | Description | Type | Default | Required |
45+
|------|-------------|------|---------|:--------:|
46+
| <a name="input_assignments_all"></a> [assignments\_all](#input\_assignments\_all) | All of account assignments. | `map(map(map(list(string))))` | n/a | yes |
47+
| <a name="input_sso_region"></a> [sso\_region](#input\_sso\_region) | Region of your AWS SSO instance. | `string` | n/a | yes |
48+
49+
## Outputs
50+
51+
No outputs.
52+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/all-in-one/backend.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
terraform {
2+
backend "local" {
3+
path = "terraform.tfstate"
4+
}
5+
}

examples/all-in-one/main.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
data "aws_ssoadmin_instances" "instances" {}
2+
3+
data "aws_organizations_organization" "organization" {}
4+
5+
locals {
6+
instance_arn = tolist(data.aws_ssoadmin_instances.instances.arns)[0]
7+
identity_store_id = tolist(data.aws_ssoadmin_instances.instances.identity_store_ids)[0]
8+
accounts = data.aws_organizations_organization.organization.accounts
9+
}
10+
11+
module "all_assignments" {
12+
source = "../.."
13+
14+
instance_arn = local.instance_arn
15+
identity_store_id = local.identity_store_id
16+
17+
organization_accounts = local.accounts
18+
19+
assignments = var.assignments_all
20+
}

examples/all-in-one/outputs.tf

Whitespace-only changes.

examples/all-in-one/providers.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "aws" {
2+
region = var.sso_region
3+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
assignments_all = {
2+
"account1" = {
3+
"groups" = {
4+
"SystemAdministrator" = [
5+
"AdministratorAccess",
6+
],
7+
"Engineer" = [
8+
"PowerUserAccess",
9+
],
10+
"Manager" = [
11+
"ReadOnlyAccess",
12+
],
13+
},
14+
"users" = {
15+
16+
"AdministratorAccess",
17+
],
18+
},
19+
},
20+
"account2" = {
21+
"groups" = {
22+
"SystemAdministrator" = [
23+
"AdministratorAccess",
24+
],
25+
"Engineer" = [
26+
"PowerUserAccess",
27+
],
28+
"Manager" = [
29+
"ReadOnlyAccess",
30+
],
31+
},
32+
"users" = {
33+
34+
"AdministratorAccess",
35+
],
36+
37+
"ReadOnlyAccess",
38+
],
39+
},
40+
},
41+
}

examples/all-in-one/variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "sso_region" {
2+
type = string
3+
description = "Region of your AWS SSO instance."
4+
}
5+
6+
variable "assignments_all" {
7+
type = map(map(map(list(string))))
8+
description = "All of account assignments."
9+
}

examples/all-in-one/version.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 0.13.7"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">=3.24.0"
8+
}
9+
}
10+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Account assignment per organization units
2+
3+
Define account assignments per organization units.
4+
5+
## Usage
6+
7+
To run this example you need to execute:
8+
9+
```bash
10+
$ terraform init
11+
$ terraform plan
12+
$ terraform apply
13+
```
14+
15+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
16+
## Requirements
17+
18+
| Name | Version |
19+
|------|---------|
20+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.7 |
21+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >=3.24.0 |
22+
23+
## Providers
24+
25+
| Name | Version |
26+
|------|---------|
27+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.24.0 |
28+
29+
## Modules
30+
31+
| Name | Source | Version |
32+
|------|--------|---------|
33+
| <a name="module_ou1_assignments"></a> [ou1\_assignments](#module\_ou1\_assignments) | ../.. | n/a |
34+
| <a name="module_ou2_assignments"></a> [ou2\_assignments](#module\_ou2\_assignments) | ../.. | n/a |
35+
36+
## Resources
37+
38+
| Name | Type |
39+
|------|------|
40+
| [aws_organizations_organization.organization](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/organizations_organization) | data source |
41+
| [aws_ssoadmin_instances.instances](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssoadmin_instances) | data source |
42+
43+
## Inputs
44+
45+
| Name | Description | Type | Default | Required |
46+
|------|-------------|------|---------|:--------:|
47+
| <a name="input_assignments_ou1"></a> [assignments\_ou1](#input\_assignments\_ou1) | Account assignments for Organization Unit 1. | `map(map(map(list(string))))` | n/a | yes |
48+
| <a name="input_assignments_ou2"></a> [assignments\_ou2](#input\_assignments\_ou2) | Account assignments for Organization Unit 2. | `map(map(map(list(string))))` | n/a | yes |
49+
| <a name="input_sso_region"></a> [sso\_region](#input\_sso\_region) | Region of your AWS SSO instance. | `string` | n/a | yes |
50+
51+
## Outputs
52+
53+
No outputs.
54+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

0 commit comments

Comments
 (0)