-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from speee/add-example
Add docs and example
- Loading branch information
Showing
18 changed files
with
398 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# All account assignments in a single module | ||
|
||
Define all account assignments in a single module. | ||
|
||
## Usage | ||
|
||
To run this example you need to execute: | ||
|
||
```bash | ||
$ terraform init | ||
$ terraform plan | ||
$ terraform apply | ||
``` | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.7 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >=3.24.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.24.0 | | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_all_assignments"></a> [all\_assignments](#module\_all\_assignments) | ../.. | n/a | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_organizations_organization.organization](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/organizations_organization) | data source | | ||
| [aws_ssoadmin_instances.instances](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssoadmin_instances) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_assignments_all"></a> [assignments\_all](#input\_assignments\_all) | All of account assignments. | `map(map(map(list(string))))` | n/a | yes | | ||
| <a name="input_sso_region"></a> [sso\_region](#input\_sso\_region) | Region of your AWS SSO instance. | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
terraform { | ||
backend "local" { | ||
path = "terraform.tfstate" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
data "aws_ssoadmin_instances" "instances" {} | ||
|
||
data "aws_organizations_organization" "organization" {} | ||
|
||
locals { | ||
instance_arn = tolist(data.aws_ssoadmin_instances.instances.arns)[0] | ||
identity_store_id = tolist(data.aws_ssoadmin_instances.instances.identity_store_ids)[0] | ||
accounts = data.aws_organizations_organization.organization.accounts | ||
} | ||
|
||
module "all_assignments" { | ||
source = "../.." | ||
|
||
instance_arn = local.instance_arn | ||
identity_store_id = local.identity_store_id | ||
|
||
organization_accounts = local.accounts | ||
|
||
assignments = var.assignments_all | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
provider "aws" { | ||
region = var.sso_region | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
assignments_all = { | ||
"account1" = { | ||
"groups" = { | ||
"SystemAdministrator" = [ | ||
"AdministratorAccess", | ||
], | ||
"Engineer" = [ | ||
"PowerUserAccess", | ||
], | ||
"Manager" = [ | ||
"ReadOnlyAccess", | ||
], | ||
}, | ||
"users" = { | ||
"alice@example.com" = [ | ||
"AdministratorAccess", | ||
], | ||
}, | ||
}, | ||
"account2" = { | ||
"groups" = { | ||
"SystemAdministrator" = [ | ||
"AdministratorAccess", | ||
], | ||
"Engineer" = [ | ||
"PowerUserAccess", | ||
], | ||
"Manager" = [ | ||
"ReadOnlyAccess", | ||
], | ||
}, | ||
"users" = { | ||
"alice@example.com" = [ | ||
"AdministratorAccess", | ||
], | ||
"bob@example.com" = [ | ||
"ReadOnlyAccess", | ||
], | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "sso_region" { | ||
type = string | ||
description = "Region of your AWS SSO instance." | ||
} | ||
|
||
variable "assignments_all" { | ||
type = map(map(map(list(string)))) | ||
description = "All of account assignments." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_version = ">= 0.13.7" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">=3.24.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Account assignment per organization units | ||
|
||
Define account assignments per organization units. | ||
|
||
## Usage | ||
|
||
To run this example you need to execute: | ||
|
||
```bash | ||
$ terraform init | ||
$ terraform plan | ||
$ terraform apply | ||
``` | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.7 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >=3.24.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.24.0 | | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_ou1_assignments"></a> [ou1\_assignments](#module\_ou1\_assignments) | ../.. | n/a | | ||
| <a name="module_ou2_assignments"></a> [ou2\_assignments](#module\_ou2\_assignments) | ../.. | n/a | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_organizations_organization.organization](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/organizations_organization) | data source | | ||
| [aws_ssoadmin_instances.instances](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssoadmin_instances) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <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 | | ||
| <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 | | ||
| <a name="input_sso_region"></a> [sso\_region](#input\_sso\_region) | Region of your AWS SSO instance. | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
terraform { | ||
backend "local" { | ||
path = "terraform.tfstate" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
data "aws_ssoadmin_instances" "instances" {} | ||
|
||
data "aws_organizations_organization" "organization" {} | ||
|
||
locals { | ||
instance_arn = tolist(data.aws_ssoadmin_instances.instances.arns)[0] | ||
identity_store_id = tolist(data.aws_ssoadmin_instances.instances.identity_store_ids)[0] | ||
accounts = data.aws_organizations_organization.organization.accounts | ||
} | ||
|
||
module "ou1_assignments" { | ||
source = "../.." | ||
|
||
instance_arn = local.instance_arn | ||
identity_store_id = local.identity_store_id | ||
|
||
organization_accounts = local.accounts | ||
|
||
assignments = var.assignments_ou1 | ||
} | ||
|
||
module "ou2_assignments" { | ||
source = "../.." | ||
|
||
instance_arn = local.instance_arn | ||
identity_store_id = local.identity_store_id | ||
|
||
organization_accounts = local.accounts | ||
|
||
assignments = var.assignments_ou2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
assignments_ou1 = { | ||
"account1" = { | ||
"groups" = { | ||
"SystemAdministrator" = [ | ||
"AdministratorAccess", | ||
], | ||
"Engineer" = [ | ||
"PowerUserAccess", | ||
], | ||
"Manager" = [ | ||
"ReadOnlyAccess", | ||
], | ||
}, | ||
"users" = { | ||
"alice@example.com" = [ | ||
"AdministratorAccess", | ||
], | ||
}, | ||
}, | ||
"account2" = { | ||
"groups" = { | ||
"SystemAdministrator" = [ | ||
"AdministratorAccess", | ||
], | ||
"Engineer" = [ | ||
"PowerUserAccess", | ||
], | ||
"Manager" = [ | ||
"ReadOnlyAccess", | ||
], | ||
}, | ||
"users" = { | ||
"alice@example.com" = [ | ||
"AdministratorAccess", | ||
], | ||
"bob@example.com" = [ | ||
"ReadOnlyAccess", | ||
], | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
assignments_ou2 = { | ||
"account3" = { | ||
"groups" = { | ||
"SystemAdministrator" = [ | ||
"AdministratorAccess", | ||
], | ||
"Manager" = [ | ||
"ReadOnlyAccess", | ||
], | ||
}, | ||
"users" = { | ||
"alice@example.com" = [ | ||
"AdministratorAccess", | ||
], | ||
}, | ||
}, | ||
"account4" = { | ||
"groups" = { | ||
"SystemAdministrator" = [ | ||
"AdministratorAccess", | ||
], | ||
}, | ||
"users" = { | ||
"alice@example.com" = [ | ||
"AdministratorAccess", | ||
], | ||
"bob@example.com" = [ | ||
"ReadOnlyAccess", | ||
], | ||
"carol@example.com" = [ | ||
"ReadOnlyAccess", | ||
], | ||
}, | ||
}, | ||
} |
Empty file.
Oops, something went wrong.