generated from trussworks/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 4
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 #1 from trussworks/populate-module
Inaugural PR
- Loading branch information
Showing
7 changed files
with
253 additions
and
32 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"default": true, | ||
"first-header-h1": false, | ||
"first-line-h1": false, | ||
"line_length": false, | ||
"no-multiple-blanks": false, | ||
"commands-show-output": false, | ||
"no-inline-html": false | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
1.4.5 | ||
1.6.3 |
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 |
---|---|---|
@@ -1 +1,71 @@ | ||
# main.tf placeholder | ||
data "aws_caller_identity" "this" {} | ||
|
||
data "aws_ssoadmin_instances" "this" {} | ||
|
||
# Identity Store Group | ||
resource "aws_identitystore_group" "this" { | ||
display_name = var.group_name | ||
description = var.group_description | ||
identity_store_id = tolist(data.aws_ssoadmin_instances.this.identity_store_ids)[0] | ||
} | ||
|
||
# Permission set | ||
resource "aws_ssoadmin_permission_set" "this" { | ||
name = var.permission_set_name | ||
description = var.permission_set_description | ||
instance_arn = tolist(data.aws_ssoadmin_instances.this.arns)[0] | ||
} | ||
|
||
# AWS-managed policy attachments | ||
resource "aws_ssoadmin_managed_policy_attachment" "this" { | ||
for_each = toset(var.policy_aws_managed) | ||
|
||
instance_arn = tolist(data.aws_ssoadmin_instances.this.arns)[0] | ||
managed_policy_arn = each.key | ||
permission_set_arn = aws_ssoadmin_permission_set.this.arn | ||
} | ||
|
||
# Customer-managed policy attachments | ||
resource "aws_ssoadmin_customer_managed_policy_attachment" "this" { | ||
count = var.policy_customer_managed_name != "" ? 1 : 0 | ||
|
||
instance_arn = tolist(data.aws_ssoadmin_instances.this.arns)[0] | ||
permission_set_arn = aws_ssoadmin_permission_set.this.arn | ||
customer_managed_policy_reference { | ||
name = var.policy_customer_managed_name | ||
path = var.policy_customer_managed_path | ||
} | ||
} | ||
|
||
# Inline policy attachments | ||
resource "aws_ssoadmin_permission_set_inline_policy" "this" { | ||
count = var.policy_inline != "" ? 1 : 0 | ||
|
||
inline_policy = var.policy_inline | ||
instance_arn = tolist(data.aws_ssoadmin_instances.this.arns)[0] | ||
permission_set_arn = aws_ssoadmin_permission_set.this.arn | ||
} | ||
|
||
# Attach Identity Store Users to Group | ||
resource "aws_identitystore_group_membership" "this" { | ||
for_each = var.users | ||
|
||
identity_store_id = tolist(data.aws_ssoadmin_instances.this.identity_store_ids)[0] | ||
group_id = aws_identitystore_group.this.group_id | ||
member_id = each.value | ||
} | ||
|
||
# Assign Accounts in which the Group can use its permission set | ||
resource "aws_ssoadmin_account_assignment" "this" { | ||
for_each = toset(var.accounts) | ||
|
||
instance_arn = tolist(data.aws_ssoadmin_instances.this.arns)[0] | ||
|
||
permission_set_arn = aws_ssoadmin_permission_set.this.arn | ||
|
||
principal_id = aws_identitystore_group.this.group_id | ||
principal_type = "GROUP" | ||
|
||
target_id = each.key | ||
target_type = "AWS_ACCOUNT" | ||
} |
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 |
---|---|---|
@@ -1 +1,10 @@ | ||
# Outputs placeholder | ||
output "group_id" { | ||
description = "the ID of the identity store group" | ||
value = aws_identitystore_group.this.group_id | ||
} | ||
|
||
output "permission_set_arn" { | ||
description = "the ARN of the permission set" | ||
value = aws_ssoadmin_permission_set.this.arn | ||
} |
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 |
---|---|---|
@@ -1 +1,55 @@ | ||
# Variables placeholder | ||
variable "accounts" { | ||
description = "List of accounts in which the permission set is to be provisioned" | ||
type = list(string) | ||
} | ||
|
||
variable "group_description" { | ||
description = "Description of the user group" | ||
type = string | ||
default = "N/A" | ||
} | ||
|
||
variable "group_name" { | ||
description = "The display name of the group being created" | ||
type = string | ||
} | ||
|
||
variable "permission_set_description" { | ||
description = "Description of the permission set" | ||
type = string | ||
default = "N/A" | ||
} | ||
|
||
variable "permission_set_name" { | ||
description = "Name of the permission set" | ||
type = string | ||
} | ||
|
||
variable "policy_aws_managed" { | ||
description = "List of ARNs of policies to attach to permission set" | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
variable "policy_customer_managed_name" { | ||
description = "Name of the policy to attach to permission set" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "policy_customer_managed_path" { | ||
description = "Path of the policy to attach to permission set" | ||
type = string | ||
default = "/" | ||
} | ||
|
||
variable "policy_inline" { | ||
description = "Inline policy in JSON format to attach to permission set" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "users" { | ||
description = "List of users to add to group" | ||
type = map(string) | ||
} |
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 |
---|---|---|
@@ -1,14 +1,7 @@ | ||
terraform { | ||
required_version = ">= 1.3.7" | ||
required_version = "~> 1.6" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 4.63.0" | ||
} | ||
aws = "~> 5.0" | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = "us-west-2" | ||
} |