Skip to content

upgrade to support terraform versions > v0.12 #35

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ provider "oci" {
*/

module "iam_compartment" {
source = "oracle-terraform-modules/iam/oci//modules/iam-compartment"
source = "oracle-terraform-modules/iam/oci//modules/iam-compartment"
# Pinning each module to a specific version is highly advisable. Please adjust and uncomment the line below
# version = "x.x.x"
tenancy_ocid = var.tenancy_ocid
Expand All @@ -51,7 +51,7 @@ module "iam_compartment" {
}

module "iam_subcompartment1" {
source = "oracle-terraform-modules/iam/oci//modules/iam-compartment"
source = "oracle-terraform-modules/iam/oci//modules/iam-compartment"
# Pinning each module to a specific version is highly advisable. Please adjust and uncomment the line below
# version = "x.x.x"
tenancy_ocid = var.tenancy_ocid
Expand All @@ -63,7 +63,7 @@ module "iam_subcompartment1" {
}

module "iam_subcompartment2" {
source = "oracle-terraform-modules/iam/oci//modules/iam-compartment"
source = "oracle-terraform-modules/iam/oci//modules/iam-compartment"
# Pinning each module to a specific version is highly advisable. Please adjust and uncomment the line below
# version = "x.x.x"
tenancy_ocid = var.tenancy_ocid
Expand All @@ -75,7 +75,7 @@ module "iam_subcompartment2" {
}

module "iam_users" {
source = "oracle-terraform-modules/iam/oci//modules/iam-user"
source = "oracle-terraform-modules/iam/oci//modules/iam-user"
# Pinning each module to a specific version is highly advisable. Please adjust and uncomment the line below
# version = "x.x.x"
tenancy_ocid = var.tenancy_ocid
Expand Down Expand Up @@ -115,7 +115,7 @@ module "iam_group" {
}

module "iam_dynamic_group" {
source = "oracle-terraform-modules/iam/oci//modules/iam-dyanmic-group"
source = "oracle-terraform-modules/iam/oci//modules/iam-dyanmic-group"
# Pinning each module to a specific version is highly advisable. Please adjust and uncomment the line below
# version = "x.x.x"
tenancy_ocid = var.tenancy_ocid
Expand Down
13 changes: 2 additions & 11 deletions modules/iam-compartment/main.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
// Copyright (c) 2018, 2021, Oracle and/or its affiliates.

terraform {
required_version = ">= 0.12" // terraform version below 0.12 is not tested/supported with this module
required_providers {
oci = {
version = ">= 3.27" // force downloading oci-provider compatible with terraform v0.12
}
}
}

########################
# Compartment
########################
Expand All @@ -32,6 +23,6 @@ data "oci_identity_compartments" "this" {
}

locals {
compartment_ids = concat(flatten(data.oci_identity_compartments.this.*.compartments), list(map("id", "")))
parent_compartment_ids = concat(flatten(data.oci_identity_compartments.this.*.compartments), list(map("compartment_id", "")))
compartment_ids = concat(flatten(data.oci_identity_compartments.this.*.compartments), tolist([tomap({ "id" = "" })]))
parent_compartment_ids = concat(flatten(data.oci_identity_compartments.this.*.compartments), tolist([tomap({ "compartment_id" = "" })]))
}
8 changes: 4 additions & 4 deletions modules/iam-compartment/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
output "compartment_id" {
description = "Compartment ocid"
// This allows the compartment ID to be retrieved from the resource if it exists, and if not to use the data source.
value = var.compartment_create ? element(concat(oci_identity_compartment.this.*.id, list("")), 0) : lookup(local.compartment_ids[0], "id")
value = var.compartment_create ? element(concat(oci_identity_compartment.this.*.id, tolist([""])), 0) : lookup(local.compartment_ids[0], "id")
}

output "parent_compartment_id" {
description = "Parent Compartment ocid"
// This allows the compartment ID to be retrieved from the resource if it exists, and if not to use the data source.
value = var.compartment_create ? element(concat(oci_identity_compartment.this.*.compartment_id, list("")), 0) : lookup(local.parent_compartment_ids[0], "compartment_id")
value = var.compartment_create ? element(concat(oci_identity_compartment.this.*.compartment_id, tolist([""])), 0) : lookup(local.parent_compartment_ids[0], "compartment_id")
}

output "compartment_name" {
description = "Compartment name"
value = var.compartment_name
value = var.compartment_name
}

output "compartment_description" {
description = "Compartment description"
value = var.compartment_description
value = var.compartment_description
}
14 changes: 7 additions & 7 deletions modules/iam-compartment/variables.tf
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
// Copyright (c) 2018, 2021, Oracle and/or its affiliates.

variable "tenancy_ocid" {
type = string
type = string
description = "(Deprecated) The OCID of the tenancy."
default = null
default = null
}

variable "compartment_id" {
type = string
type = string
description = "The OCID of the parent compartment containing the compartment. Allow for sub-compartments creation"
default = null
}

variable "compartment_name" {
type = string
type = string
description = "The name you assign to the compartment during creation. The name must be unique across all compartments in the tenancy. "
default = null
}

// The description is only used if compartment_create = true.
variable "compartment_description" {
type = string
type = string
description = "The description you assign to the compartment. Does not have to be unique, and it's changeable. "
default = null
}

variable "compartment_create" {
type = bool
type = bool
description = "(Deprecated) Create the compartment or not. If true, the compartment will be managed by this module, and the user must have permissions to create the compartment; If false, compartment data will be returned about the compartment if it exists, if not found, then an empty string will be returned for the compartment ID."
default = true
}

variable "enable_delete" {
type = bool
type = bool
description = "Enable compartment delete on destroy. If true, compartment will be deleted when `terraform destroy` is executed; If false, compartment will not be deleted on `terraform destroy` execution"
default = false
}
2 changes: 1 addition & 1 deletion modules/iam-dynamic-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ data "oci_identity_dynamic_groups" "this" {
}

locals {
dynamic_group_ids = concat(flatten(data.oci_identity_dynamic_groups.this.*.dynamic_groups), list(map("id", "")))
dynamic_group_ids = concat(flatten(data.oci_identity_dynamic_groups.this.*.dynamic_groups), tolist([tomap({ "id" = "" })]))
}

########################
Expand Down
6 changes: 3 additions & 3 deletions modules/iam-dynamic-group/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

output "dynamic_group_id" {
description = "Dynamic Group ocid"
value = var.dynamic_group_create ? element(concat(oci_identity_dynamic_group.this.*.id, list("")), 0) : lookup(local.dynamic_group_ids[0], "id")
value = var.dynamic_group_create ? element(concat(oci_identity_dynamic_group.this.*.id, tolist([""])), 0) : lookup(local.dynamic_group_ids[0], "id")
}

output "dynamic_group_name" {
description = "Dynamic Group name"
value = var.dynamic_group_name
value = var.dynamic_group_name
}

output "name_ocid" {
Expand All @@ -16,5 +16,5 @@ output "name_ocid" {
}
output "dynamic_group_policy_name" {
description = "Dynamic Group policy name"
value = var.policy_name
value = var.policy_name
}
22 changes: 11 additions & 11 deletions modules/iam-dynamic-group/variables.tf
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
// Copyright (c) 2018, 2021, Oracle and/or its affiliates.

variable "tenancy_ocid" {
type = string
type = string
description = "The OCID of the tenancy."
default = null
default = null
}

variable "dynamic_group_name" {
type = string
type = string
description = "The name you assign to the group during creation. The name must be unique across all compartments in the tenancy. "
default = null
default = null
}

variable "dynamic_group_description" {
type = string
type = string
description = "The description you assign to the Group. Does not have to be unique, and it's changeable. "
default = null
}

variable "dynamic_group_create" {
type = bool
type = bool
description = "(Deprecated) Create the dynamic group or not. If true, the user must have permissions to create the group; If false, group data will be returned about the group if it exists, if not found, then an empty string will be returned for the group ID."
default = true
}

variable "matching_rule" {
type = string
type = string
description = "Define a matching rule or a set of matching rules to define the group members."
default = null
}

variable "policy_name" {
type = string
type = string
description = "The name you assign to the policy during creation. "
default = null
}

variable "policy_description" {
type = string
type = string
description = "The description you assign to the policy. Does not have to be unique, and it's changeable. "
default = null
}

variable "policy_statements" {
type = list(string)
type = list(string)
description = "Define policy consists of one or more policy statements. "
default = null
}

variable "policy_compartment_id" {
type = string
type = string
description = "The compartment id assign to policy."
default = null
}
4 changes: 2 additions & 2 deletions modules/iam-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ data "oci_identity_groups" "this" {
}

locals {
group_ids = concat(flatten(data.oci_identity_groups.this.*.groups), list(map("id", "")))
group_ids = concat(flatten(data.oci_identity_groups.this.*.groups), tolist([tomap({ "id" = "" })]))
}

########################
Expand All @@ -30,7 +30,7 @@ locals {
resource "oci_identity_user_group_membership" "this" {
count = var.user_ids == null ? 0 : length(var.user_ids)
user_id = var.user_ids[count.index]
group_id = var.group_create ? element(concat(oci_identity_group.this.*.id, list("")), 0) : lookup(local.group_ids[0], "id")
group_id = var.group_create ? element(concat(oci_identity_group.this.*.id, tolist([""])), 0) : lookup(local.group_ids[0], "id")
}

########################
Expand Down
8 changes: 4 additions & 4 deletions modules/iam-group/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

output "group_id" {
description = "Group ocid"
value = var.group_create ? element(concat(oci_identity_group.this.*.id, list("")), 0) : lookup(local.group_ids[0], "id")
value = var.group_create ? element(concat(oci_identity_group.this.*.id, tolist([""])), 0) : lookup(local.group_ids[0], "id")
}

output "group_name" {
description = "Group name"
value = var.group_name
value = var.group_name
}

output "name_ocid" {
Expand All @@ -17,10 +17,10 @@ output "name_ocid" {

output "group_description" {
description = "Group description"
value = var.group_description
value = var.group_description
}

output "group_policy_name" {
description = "Group policy name"
value = var.policy_name
value = var.policy_name
}
22 changes: 11 additions & 11 deletions modules/iam-group/variables.tf
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
// Copyright (c) 2018, 2021, Oracle and/or its affiliates.

variable "tenancy_ocid" {
type = string
type = string
description = "The OCID of the tenancy."
default = null
default = null
}

variable "group_name" {
type = string
type = string
description = "The name you assign to the group during creation. The name must be unique across all compartments in the tenancy."
default = null
default = null
}

// The description is only used if group_create = true.
variable "group_description" {
type = string
type = string
description = "The description you assign to the Group. Does not have to be unique, and it's changeable. "
default = null
}

variable "group_create" {
type = bool
type = bool
description = "(Deprecated) Create the group or not. If true, the user must have permissions to create the group; If false, group data will be returned about the group if it exists, if not found, then an empty string will be returned for the group ID."
default = true
}

variable "user_ids" {
type = list(string)
type = list(string)
description = "List of user ocids to be added as group member"
default = null
}

variable "policy_name" {
type = string
type = string
description = "The name you assign to the policy during creation. "
default = null
}

variable "policy_description" {
type = string
type = string
description = "The description you assign to the policy. Does not have to be unique, and it's changeable. "
default = null
}

variable "policy_statements" {
type = list(string)
type = list(string)
description = "Define policy consists of one or more policy statements. "
default = null
}

variable "policy_compartment_id" {
type = string
type = string
description = "The compartment id where policy is created."
default = null
}
10 changes: 5 additions & 5 deletions modules/iam-user/variables.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Copyright (c) 2018, 2021, Oracle and/or its affiliates.

variable "tenancy_ocid" {
type = string
type = string
description = "The OCID of the tenancy."
default = null
default = null
}

variable users {
variable "users" {
description = "The name and description you assign to the user during creation. The name must be unique across all compartments in the tenancy. "
type = list(object({
name = string
name = string
description = string
email = string
email = string
}))
default = null
}