Skip to content

Commit

Permalink
initial configuration of permission set and policies
Browse files Browse the repository at this point in the history
  • Loading branch information
zachreborn committed Dec 30, 2023
1 parent 2ab1834 commit 838f833
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
39 changes: 39 additions & 0 deletions modules/aws/identity_center/permission_set/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
###########################
# Provider Configuration
###########################
terraform {
required_version = ">= 1.0.0"
required_providers {
Expand All @@ -8,8 +11,20 @@ terraform {
}
}

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

data "aws_ssoadmin_instances" "this" {}

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

###########################
# Permission Set
###########################

resource "aws_ssoadmin_permission_set" "this" {
name = var.name
description = var.description
Expand All @@ -18,3 +33,27 @@ resource "aws_ssoadmin_permission_set" "this" {
session_duration = var.session_duration
tags = merge(var.tags, { "Name" = var.name })
}

resource "aws_ssoadmin_customer_managed_policy_attachment" "this" {
count = var.customer_managed_iam_policy_name != null ? 1 : 0
instance_arn = aws_ssoadmin_permission_set.this.instance_arn
permission_set_arn = aws_ssoadmin_permission_set.this.arn
customer_managed_policy_reference {
name = var.customer_managed_iam_policy_name
path = var.customer_managed_iam_policy_path
}
}

resource "aws_ssoadmin_managed_policy_attachment" "this" {
count = var.managed_policy_arn != null ? 1 : 0
instance_arn = aws_ssoadmin_permission_set.this.instance_arn
managed_policy_arn = var.managed_policy_arn
permission_set_arn = aws_ssoadmin_permission_set.this.arn
}

resource "aws_ssoadmin_permission_set_inline_policy" "this" {
count = var.inline_policy != null ? 1 : 0
inline_policy = var.inline_policy
instance_arn = aws_ssoadmin_permission_set.this.instance_arn
permission_set_arn = aws_ssoadmin_permission_set.this.arn
}
24 changes: 24 additions & 0 deletions modules/aws/identity_center/permission_set/variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
variable "customer_managed_iam_policy_name" {
description = "(Optional) The name of the customer managed IAM policy to attach to a Permission Set. If this is set, the module will utilize a customer_managed_policy_attachment."
type = string
default = null
}

variable "customer_managed_iam_policy_path" {
description = "(Optional) The path of the customer managed IAM policy to attach to a Permission Set."
type = string
default = "/"
}

variable "description" {
description = "(Optional) The description of the permission set."
type = string
default = null
}

variable "inline_policy" {
description = "(Optional) The IAM inline policy to attach to a Permission Set. If this is set, the module will utilize an inline_policy."
type = string
default = null
}

variable "managed_policy_arn" {
description = "(Optional) The ARN of the IAM managed policy to attach to a Permission Set. If this is set, the module will utilize a managed_policy_attachment."
type = string
default = null
}

variable "name" {
description = "(Required) The name of the permission set."
type = string
Expand Down
25 changes: 25 additions & 0 deletions modules/module_template/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
###########################
# Provider Configuration
###########################
terraform {
required_version = ">= 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0.0"
}
}
}

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


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

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

0 comments on commit 838f833

Please sign in to comment.