Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2024.4.0 #7

Merged
merged 9 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions modules/identity/iam-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,43 @@
# Resource Block - Identity
# Create Groups
############################

locals {
user_ids = {
for user in data.oci_identity_users.users.users :
user.name => user.id
}
}
resource "oci_identity_group" "group" {
count = (var.matching_rule != "" && var.matching_rule != null) ? 0 : 1

#Required
compartment_id = var.tenancy_ocid
description = var.group_description
name = var.group_name

#Optional
defined_tags = var.defined_tags
freeform_tags = var.freeform_tags

}

resource "oci_identity_user_group_membership" "user_group_membership" {
for_each = {
for member in var.members : member => member
}
group_id = oci_identity_group.group[0].id
user_id = local.user_ids[each.key]
}
############################
# Resource Block - Identity
# Create Dynamic Groups
############################

resource "oci_identity_dynamic_group" "dynamic_group" {
count = (var.matching_rule != "" && var.matching_rule != null) ? 1 : 0

#Required
compartment_id = var.tenancy_ocid
description = var.group_description
matching_rule = var.matching_rule
name = var.group_name

#Optional
defined_tags = var.defined_tags
freeform_tags = var.freeform_tags

lifecycle {
ignore_changes = [defined_tags["Oracle-Tags.CreatedOn"], defined_tags["Oracle-Tags.CreatedBy"]]
}
Expand Down
12 changes: 12 additions & 0 deletions modules/identity/iam-group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ variable "tenancy_ocid" {
default = null
}

variable "members" {
description = "List of members"
type = list(string)
default = []
}

variable "group_membership" {
type = list(string)
description = "The name of the group user is member of."
default = []
}

variable "group_name" {
type = string
description = "The name you assign to the group during creation. The name must be unique across all compartments in the tenancy."
Expand Down
20 changes: 6 additions & 14 deletions modules/identity/iam-user/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,14 @@ resource "oci_identity_user" "user" {

}

resource "oci_identity_user_group_membership" "user_group_membership" {
count = var.group_membership != null ? length(var.group_membership) : 0
depends_on = [oci_identity_user.user]
user_id = oci_identity_user.user.id
group_id = length(regexall("ocid1.group.oc*", var.group_membership[count.index])) > 0 ? var.group_membership[count.index] : data.oci_identity_groups.iam_groups.groups[index(data.oci_identity_groups.iam_groups.groups.*.name, var.group_membership[count.index])].id
}

resource "oci_identity_user_capabilities_management" "user_capabilities_management" {
count = var.disable_capabilities != null ? 1 : 0
count = var.enabled_capabilities != null ? 1 : 0
depends_on = [oci_identity_user.user]
user_id = oci_identity_user.user.id

can_use_api_keys = var.disable_capabilities != null && contains(var.disable_capabilities, "can_use_api_keys") ? false : true
can_use_auth_tokens = var.disable_capabilities != null && contains(var.disable_capabilities, "can_use_auth_tokens") ? false : true
can_use_console_password = var.disable_capabilities != null && contains(var.disable_capabilities, "can_use_console_password") ? false : true
can_use_customer_secret_keys = var.disable_capabilities != null && contains(var.disable_capabilities, "can_use_customer_secret_keys") ? false : true
can_use_smtp_credentials = var.disable_capabilities != null && contains(var.disable_capabilities, "can_use_smtp_credentials") ? false : true

can_use_api_keys = contains(var.enabled_capabilities, "api_keys") ? true :false
can_use_auth_tokens = contains(var.enabled_capabilities, "auth_tokens") ? true :false
can_use_console_password = contains(var.enabled_capabilities, "console_password") ? true :false
can_use_customer_secret_keys = contains(var.enabled_capabilities, "customer_secret_keys") ? true :false
can_use_smtp_credentials = contains(var.enabled_capabilities, "smtp_credentials") ? true :false
}
4 changes: 2 additions & 2 deletions modules/identity/iam-user/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ variable "user_email" {
default = null
}

variable "disable_capabilities" {
variable "enabled_capabilities" {
type = list(string)
description = "The name of the capabilities disabled for user"
description = "The name of the capabilities enabled for user"
default = []
}

Expand Down