Skip to content

Commit d0f017a

Browse files
committed
📦 NEW: initial commit
0 parents  commit d0f017a

File tree

11 files changed

+256
-0
lines changed

11 files changed

+256
-0
lines changed

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
# Created by https://www.gitignore.io/api/macos,terraform
3+
# Edit at https://www.gitignore.io/?templates=macos,terraform
4+
5+
### macOS ###
6+
# General
7+
.DS_Store
8+
.AppleDouble
9+
.LSOverride
10+
11+
# Icon must end with two \r
12+
Icon
13+
14+
# Thumbnails
15+
._*
16+
17+
# Files that might appear in the root of a volume
18+
.DocumentRevisions-V100
19+
.fseventsd
20+
.Spotlight-V100
21+
.TemporaryItems
22+
.Trashes
23+
.VolumeIcon.icns
24+
.com.apple.timemachine.donotpresent
25+
26+
# Directories potentially created on remote AFP share
27+
.AppleDB
28+
.AppleDesktop
29+
Network Trash Folder
30+
Temporary Items
31+
.apdisk
32+
33+
### Terraform ###
34+
.terraform.lock.hcl
35+
36+
# Local .terraform directories
37+
**/.terraform/*
38+
39+
# .tfstate files
40+
*.tfstate
41+
*.tfstate.*
42+
43+
# Crash log files
44+
crash.log
45+
46+
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
47+
# .tfvars files are managed as part of configuration and so should be included in
48+
# version control.
49+
#
50+
# example.tfvars
51+
52+
# Ignore override files as they are usually used to override resources locally and so
53+
# are not checked in
54+
override.tf
55+
override.tf.json
56+
*_override.tf
57+
*_override.tf.json
58+
59+
# Include override files you do wish to add to version control using negated pattern
60+
# !example_override.tf
61+
62+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
63+
# example: *tfplan*
64+
65+
# End of https://www.gitignore.io/api/macos,terraform

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## V0.1.0
4+
5+
Initial release.

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <https://unlicense.org>

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# terraform-aws-sso
2+
3+
## Requirements/Assumptions
4+
5+
- AWS ORG created, with SSO enabled.
6+
- AWS SSO enabled in target Account.
7+
- AWS SSO Group is created.

data.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
data "aws_organizations_organization" "this" {}
2+
3+
data "aws_ssoadmin_instances" "this" {}
4+
5+
data "aws_identitystore_group" "this" {
6+
identity_store_id = tolist(data.aws_ssoadmin_instances.this.identity_store_ids)[0]
7+
filter {
8+
attribute_path = "DisplayName"
9+
attribute_value = var.group_display_name
10+
}
11+
}
12+
13+
# Future use
14+
# data "aws_identitystore_user" "this" {
15+
#
16+
# }

examples/simple/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Simple AWS SSO Permission Set
2+
3+
This example will create an SSO Permission Set, attach managed policy and existing Group to target account.
4+
5+
## How to apply
6+
7+
```bash
8+
terraform init
9+
terraform plan
10+
terraform apply
11+
```
12+
13+
## How to destroy
14+
15+
```bash
16+
terraform destroy
17+
```

examples/simple/main.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
provider "aws" {
2+
region = "eu-west-1"
3+
}
4+
5+
module "permission_set" {
6+
source = "../../"
7+
8+
name = "DevAdmins"
9+
description = "DevAdmins permission set"
10+
group_display_name = "Developers"
11+
session_duration = "PT2H"
12+
target_id = "123456789000"
13+
managed_policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
14+
15+
tags = {
16+
Just_For_Testing = "True"
17+
Remove_Me = "Please"
18+
}
19+
}
20+
21+

main.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
resource "aws_ssoadmin_account_assignment" "this" {
2+
instance_arn = aws_ssoadmin_permission_set.this.instance_arn
3+
permission_set_arn = aws_ssoadmin_permission_set.this.arn
4+
principal_id = data.aws_identitystore_group.this.group_id
5+
principal_type = "GROUP"
6+
target_type = "AWS_ACCOUNT"
7+
target_id = var.target_id
8+
}
9+
10+
resource "aws_ssoadmin_permission_set" "this" {
11+
name = var.name
12+
description = var.description
13+
instance_arn = tolist(data.aws_ssoadmin_instances.this.arns)[0]
14+
relay_state = var.relay_state
15+
session_duration = var.session_duration
16+
tags = var.tags
17+
}
18+
19+
resource "aws_ssoadmin_managed_policy_attachment" "this" {
20+
instance_arn = aws_ssoadmin_permission_set.this.instance_arn
21+
permission_set_arn = aws_ssoadmin_permission_set.this.arn
22+
managed_policy_arn = var.managed_policy_arn
23+
}
24+
25+
26+
# Future use
27+
# resource "aws_ssoadmin_permission_set_inline_policy" "this" {
28+
# inline_policy = var.inline_policy
29+
# instance_arn = aws_ssoadmin_permission_set.this.instance_arn
30+
# permission_set_arn = aws_ssoadmin_permission_set.this.arn
31+
# }

outputs.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
output "account_names" {
2+
value = data.aws_organizations_organization.this.accounts[*].name
3+
}
4+
5+
output "account_ids" {
6+
value = data.aws_organizations_organization.this.accounts[*].id
7+
}
8+
9+
output "ssoadmin_instance_arn" {
10+
value = tolist(data.aws_ssoadmin_instances.this.arns)[0]
11+
}
12+
13+
output "identity_store_id" {
14+
value = tolist(data.aws_ssoadmin_instances.this.identity_store_ids)[0]
15+
}

variables.tf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
variable "group_display_name" {
2+
type = string
3+
description = "The group's display name value"
4+
}
5+
6+
variable "name" {
7+
type = string
8+
description = "(Required, Forces new resource) The name of the Permission Set."
9+
}
10+
11+
variable "tags" {
12+
type = map(string)
13+
description = "(Optional) Key-value map of resource tags."
14+
default = {
15+
Terraform = "Yes"
16+
}
17+
}
18+
variable "description" {
19+
type = string
20+
default = ""
21+
description = "(Optional) The description of the Permission Set."
22+
}
23+
variable "relay_state" {
24+
type = string
25+
default = null
26+
description = "(Optional) The relay state URL used to redirect users within the application during the federation authentication process."
27+
}
28+
variable "session_duration" {
29+
type = string
30+
default = "PT1H"
31+
description = "(Optional) The length of time that the application user sessions are valid in the ISO-8601 standard. Default: PT1H."
32+
}
33+
34+
variable "target_id" {
35+
type = string
36+
description = "(Required, Forces new resource) An AWS account identifier, typically a 10-12 digit string."
37+
}
38+
39+
variable "managed_policy_arn" {
40+
type = string
41+
description = "describe your variable"
42+
}
43+
44+
# future use
45+
# variable "inline_policy" {
46+
# type = any
47+
# description = "describe your variable"
48+
# }

0 commit comments

Comments
 (0)