Skip to content

Commit 46d9f87

Browse files
Merge pull request #5 from oracle-quickstart/issue-4-cmp-data-source
Issue 4 cmp data source
2 parents dcc3a1c + 8f5f15d commit 46d9f87

40 files changed

+297
-209
lines changed

RELEASE-NOTES.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
# March 30, 2023 Release Notes - 0.1.0
1+
# March 30, 2023 Release Notes - 0.1.1
22

33
## Added
44
1. [Initial Release](#0-1-0-initial)
55

66
### <a name="0-1-0-initial">Initial Release</a>
7-
Modules for compartments, policies, groups and dynamic groups.
7+
Modules for compartments, policies, groups and dynamic groups.
8+
9+
# May 15, 2023 Release Notes - 0.1.1
10+
11+
## Updates
12+
1. [Policy Module](#0-1-1-policies)
13+
### <a name="0-1-1-policies">Policy Module</a>
14+
- Policy target compartments must be passed as a map of objects via *supplied_compartments* attribute.
15+
- Policy examples updated, showcasing template policies and supplied policies.

compartments/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ module "compartments" {
8080
For invoking the module remotely, set the module *source* attribute to the compartments module folder in this repository, as shown:
8181
```
8282
module "compartments" {
83-
source = "git@github.com:oracle-quickstart/terraform-oci-cis-landing-zone-iam-modules.git//compartments"
83+
source = "git@github.com:oracle-quickstart/terraform-oci-cis-landing-zone-iam.git//compartments"
8484
compartments_configuration = var.compartments_configuration
8585
}
8686
```
8787
For referring to a specific module version, append *ref=\<version\>* to the *source* attribute value, as in:
8888
```
89-
source = "git@github.com:oracle-quickstart/terraform-oci-cis-landing-zone-iam-modules.git//compartments?ref=v0.1.0"
89+
source = "git@github.com:oracle-quickstart/terraform-oci-cis-landing-zone-iam.git//compartments?ref=v0.1.0"
9090
```
9191

9292
## Related Documentation

compartments/SPEC.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ No modules.
3131
| Name | Description | Type | Default | Required |
3232
|------|-------------|------|---------|:--------:|
3333
| <a name="input_compartments_configuration"></a> [compartments\_configuration](#input\_compartments\_configuration) | The compartments configuration. Use the compartments attribute to define your topology. OCI supports compartment hierarchies up to six levels. | <pre>object({<br> default_parent_ocid = optional(string) # the default parent for all top (first level) compartments. Use parent_ocid attribute within each compartment to specify different parents.<br> default_defined_tags = optional(map(string)) # applies to all compartments, unless overriden by defined_tags in a compartment object<br> default_freeform_tags = optional(map(string)) # applies to all compartments, unless overriden by freeform_tags in a compartment object<br> enable_delete = optional(bool) # whether or not compartments are physically deleted when destroyed. Default is false.<br> compartments = map(object({<br> name = string<br> description = string<br> parent_ocid = optional(string)<br> defined_tags = optional(map(string))<br> freeform_tags = optional(map(string))<br> tag_defaults = optional(map(object({<br> tag_ocid = string,<br> default_value = string,<br> is_user_required = optional(bool)<br> })))<br> children = optional(map(object({<br> name = string<br> description = string<br> defined_tags = optional(map(string))<br> freeform_tags = optional(map(string))<br> tag_defaults = optional(map(object({<br> tag_ocid = string,<br> default_value = string,<br> is_user_required = optional(bool)<br> })))<br> children = optional(map(object({<br> name = string<br> description = string<br> defined_tags = optional(map(string))<br> freeform_tags = optional(map(string))<br> tag_defaults = optional(map(object({<br> tag_ocid = string,<br> default_value = string,<br> is_user_required = optional(bool)<br> })))<br> children = optional(map(object({<br> name = string<br> description = string<br> defined_tags = optional(map(string))<br> freeform_tags = optional(map(string))<br> tag_defaults = optional(map(object({<br> tag_ocid = string,<br> default_value = string,<br> is_user_required = optional(bool)<br> })))<br> children = optional(map(object({<br> name = string<br> description = string<br> defined_tags = optional(map(string))<br> freeform_tags = optional(map(string))<br> tag_defaults = optional(map(object({<br> tag_ocid = string,<br> default_value = string,<br> is_user_required = optional(bool)<br> })))<br> children = optional(map(object({<br> name = string<br> description = string<br> defined_tags = optional(map(string))<br> freeform_tags = optional(map(string))<br> tag_defaults = optional(map(object({<br> tag_ocid = string,<br> default_value = string,<br> is_user_required = optional(bool)<br> })))<br> }))) <br> })))<br> })))<br> })))<br> }))) <br> }))<br> })</pre> | n/a | yes |
34+
| <a name="input_module_name"></a> [module\_name](#input\_module\_name) | The module name. | `string` | `"iam-compartments"` | no |
3435
| <a name="input_tenancy_ocid"></a> [tenancy\_ocid](#input\_tenancy\_ocid) | The OCID of the tenancy. | `string` | n/a | yes |
3536

3637
## Outputs

compartments/main.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ locals {
1010
description = v1.description
1111
parent_ocid = v1.parent_ocid != null ? v1.parent_ocid : var.compartments_configuration.default_parent_ocid != null ? var.compartments_configuration.default_parent_ocid : var.tenancy_ocid
1212
defined_tags = v1.defined_tags != null ? v1.defined_tags : var.compartments_configuration.default_defined_tags != null ? var.compartments_configuration.default_defined_tags : null
13-
freeform_tags = v1.freeform_tags != null ? v1.freeform_tags : var.compartments_configuration.default_freeform_tags ? var.compartments_configuration.default_freeform_tags : null
13+
freeform_tags = v1.freeform_tags != null ? v1.freeform_tags : var.compartments_configuration.default_freeform_tags != null ? var.compartments_configuration.default_freeform_tags : null
1414
tag_defaults = v1.tag_defaults
1515
enable_delete = var.compartments_configuration.enable_delete != null ? var.compartments_configuration.enable_delete : false
1616
}
@@ -24,7 +24,7 @@ locals {
2424
description = v2.description
2525
parent_ocid = oci_identity_compartment.these[k1].id
2626
defined_tags = v2.defined_tags != null ? v2.defined_tags : var.compartments_configuration.default_defined_tags != null ? var.compartments_configuration.default_defined_tags : null
27-
freeform_tags = v2.freeform_tags != null ? v2.freeform_tags : var.compartments_configuration.default_freeform_tags ? var.compartments_configuration.default_freeform_tags : null
27+
freeform_tags = v2.freeform_tags != null ? v2.freeform_tags : var.compartments_configuration.default_freeform_tags != null ? var.compartments_configuration.default_freeform_tags : null
2828
tag_defaults = v2.tag_defaults
2929
enable_delete = var.compartments_configuration.enable_delete != null ? var.compartments_configuration.enable_delete : false
3030
}
@@ -40,7 +40,7 @@ locals {
4040
description = v3.description
4141
parent_ocid = oci_identity_compartment.level_2[k2].id
4242
defined_tags = v3.defined_tags != null ? v3.defined_tags : var.compartments_configuration.default_defined_tags != null ? var.compartments_configuration.default_defined_tags : null
43-
freeform_tags = v3.freeform_tags != null ? v3.freeform_tags : var.compartments_configuration.default_freeform_tags ? var.compartments_configuration.default_freeform_tags : null
43+
freeform_tags = v3.freeform_tags != null ? v3.freeform_tags : var.compartments_configuration.default_freeform_tags != null ? var.compartments_configuration.default_freeform_tags : null
4444
tag_defaults = v3.tag_defaults
4545
enable_delete = var.compartments_configuration.enable_delete != null ? var.compartments_configuration.enable_delete : false
4646
}
@@ -58,7 +58,7 @@ locals {
5858
description = v4.description
5959
parent_ocid = oci_identity_compartment.level_3[k3].id
6060
defined_tags = v4.defined_tags != null ? v4.defined_tags : var.compartments_configuration.default_defined_tags != null ? var.compartments_configuration.default_defined_tags : null
61-
freeform_tags = v4.freeform_tags != null ? v4.freeform_tags : var.compartments_configuration.default_freeform_tags ? var.compartments_configuration.default_freeform_tags : null
61+
freeform_tags = v4.freeform_tags != null ? v4.freeform_tags : var.compartments_configuration.default_freeform_tags != null ? var.compartments_configuration.default_freeform_tags : null
6262
tag_defaults = v4.tag_defaults
6363
enable_delete = var.compartments_configuration.enable_delete != null ? var.compartments_configuration.enable_delete : false
6464
}
@@ -78,7 +78,7 @@ locals {
7878
description = v5.description
7979
parent_ocid = oci_identity_compartment.level_4[k4].id
8080
defined_tags = v5.defined_tags != null ? v5.defined_tags : var.compartments_configuration.default_defined_tags != null ? var.compartments_configuration.default_defined_tags : null
81-
freeform_tags = v5.freeform_tags != null ? v5.freeform_tags : var.compartments_configuration.default_freeform_tags ? var.compartments_configuration.default_freeform_tags : null
81+
freeform_tags = v5.freeform_tags != null ? v5.freeform_tags : var.compartments_configuration.default_freeform_tags != null ? var.compartments_configuration.default_freeform_tags : null
8282
tag_defaults = v5.tag_defaults
8383
enable_delete = var.compartments_configuration.enable_delete != null ? var.compartments_configuration.enable_delete : false
8484
}
@@ -100,7 +100,7 @@ locals {
100100
description = v6.description
101101
parent_ocid = oci_identity_compartment.level_5[k5].id
102102
defined_tags = v6.defined_tags != null ? v6.defined_tags : var.compartments_configuration.default_defined_tags != null ? var.compartments_configuration.default_defined_tags : null
103-
freeform_tags = v6.freeform_tags != null ? v6.freeform_tags : var.compartments_configuration.default_freeform_tags ? var.compartments_configuration.default_freeform_tags : null
103+
freeform_tags = v6.freeform_tags != null ? v6.freeform_tags : var.compartments_configuration.default_freeform_tags != null ? var.compartments_configuration.default_freeform_tags : null
104104
tag_defaults = v6.tag_defaults
105105
enable_delete = var.compartments_configuration.enable_delete != null ? var.compartments_configuration.enable_delete : false
106106
}
@@ -140,7 +140,7 @@ resource "oci_identity_compartment" "these" {
140140
description = each.value.description
141141
enable_delete = each.value.enable_delete
142142
defined_tags = each.value.defined_tags
143-
freeform_tags = each.value.freeform_tags
143+
freeform_tags = merge(local.cislz_module_tag, each.value.freeform_tags)
144144
}
145145

146146
resource "oci_identity_compartment" "level_2" {
@@ -155,7 +155,7 @@ resource "oci_identity_compartment" "level_2" {
155155
description = each.value.description
156156
enable_delete = each.value.enable_delete
157157
defined_tags = each.value.defined_tags
158-
freeform_tags = each.value.freeform_tags
158+
freeform_tags = merge(local.cislz_module_tag, each.value.freeform_tags)
159159
}
160160

161161
resource "oci_identity_compartment" "level_3" {
@@ -170,7 +170,7 @@ resource "oci_identity_compartment" "level_3" {
170170
description = each.value.description
171171
enable_delete = each.value.enable_delete
172172
defined_tags = each.value.defined_tags
173-
freeform_tags = each.value.freeform_tags
173+
freeform_tags = merge(local.cislz_module_tag, each.value.freeform_tags)
174174
}
175175

176176
resource "oci_identity_compartment" "level_4" {
@@ -185,7 +185,7 @@ resource "oci_identity_compartment" "level_4" {
185185
description = each.value.description
186186
enable_delete = each.value.enable_delete
187187
defined_tags = each.value.defined_tags
188-
freeform_tags = each.value.freeform_tags
188+
freeform_tags = merge(local.cislz_module_tag, each.value.freeform_tags)
189189
}
190190

191191
resource "oci_identity_compartment" "level_5" {
@@ -200,7 +200,7 @@ resource "oci_identity_compartment" "level_5" {
200200
description = each.value.description
201201
enable_delete = each.value.enable_delete
202202
defined_tags = each.value.defined_tags
203-
freeform_tags = each.value.freeform_tags
203+
freeform_tags = merge(local.cislz_module_tag, each.value.freeform_tags)
204204
}
205205

206206
resource "oci_identity_compartment" "level_6" {
@@ -215,7 +215,7 @@ resource "oci_identity_compartment" "level_6" {
215215
description = each.value.description
216216
enable_delete = each.value.enable_delete
217217
defined_tags = each.value.defined_tags
218-
freeform_tags = each.value.freeform_tags
218+
freeform_tags = merge(local.cislz_module_tag, each.value.freeform_tags)
219219
}
220220

221221
resource "oci_identity_tag_default" "these" {

compartments/metadata.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2023 Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
#-- Used to inform module and release number.
5+
locals {
6+
cislz_module_tag = {"cislz-terraform-module" : fileexists("${path.module}/../release.txt") ? "${var.module_name}/${file("${path.module}/../release.txt")}" : "${var.module_name}"}
7+
}

compartments/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,10 @@ variable "compartments_configuration" {
8484
})))
8585
}))
8686
})
87+
}
88+
89+
variable module_name {
90+
description = "The module name."
91+
type = string
92+
default = "iam-compartments"
8793
}

dynamic-groups/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ module "dynamic-groups" {
5757
For invoking the module remotely, set the module *source* attribute to the dynamic-groups module folder in this repository, as shown:
5858
```
5959
module "dynamic-groups" {
60-
source = "git@github.com:oracle-quickstart/terraform-oci-cis-landing-zone-iam-modules.git//dynamic-groups"
60+
source = "git@github.com:oracle-quickstart/terraform-oci-cis-landing-zone-iam.git//dynamic-groups"
6161
tenancy_id = var.tenancy_id
6262
dynamic_groups_configuration = var.dynamic_groups_configuration
6363
}
6464
```
6565
For referring to a specific module version, append *ref=\<version\>* to the *source* attribute value, as in:
6666
```
67-
source = "git@github.com:oracle-quickstart/terraform-oci-cis-landing-zone-iam-modules.git//dynamic-groups?ref=v0.1.0"
67+
source = "git@github.com:oracle-quickstart/terraform-oci-cis-landing-zone-iam.git//dynamic-groups?ref=v0.1.0"
6868
```
6969

7070
## Related Documentation

dynamic-groups/SPEC.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ No modules.
2525
| Name | Description | Type | Default | Required |
2626
|------|-------------|------|---------|:--------:|
2727
| <a name="input_dynamic_groups_configuration"></a> [dynamic\_groups\_configuration](#input\_dynamic\_groups\_configuration) | The dynamic groups. | <pre>object({<br> default_defined_tags = optional(map(string)),<br> default_freeform_tags = optional(map(string))<br> dynamic_groups = map(object({<br> name = string,<br> description = string,<br> matching_rule = string<br> defined_tags = optional(map(string)),<br> freeform_tags = optional(map(string))<br> }))<br> })</pre> | n/a | yes |
28+
| <a name="input_module_name"></a> [module\_name](#input\_module\_name) | The module name. | `string` | `"iam-dynamic-groups"` | no |
2829
| <a name="input_tenancy_ocid"></a> [tenancy\_ocid](#input\_tenancy\_ocid) | The OCID of the tenancy. | `any` | n/a | yes |
2930

3031
## Outputs

dynamic-groups/examples/vision/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
variable "tenancy_ocid" {}
5-
vvariable "region" {description = "Your tenancy home region"}
5+
variable "region" {description = "Your tenancy home region"}
66
variable "user_ocid" {default = ""}
77
variable "fingerprint" {default = ""}
88
variable "private_key_path" {default = ""}

dynamic-groups/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ resource "oci_identity_dynamic_group" "these" {
88
compartment_id = var.tenancy_ocid
99
matching_rule = each.value.matching_rule
1010
defined_tags = each.value.defined_tags != null ? each.value.defined_tags : var.dynamic_groups_configuration.default_defined_tags != null ? var.dynamic_groups_configuration.default_defined_tags : null
11-
freeform_tags = each.value.freeform_tags != null ? each.value.freeform_tags : var.dynamic_groups_configuration.default_freeform_tags != null ? var.dynamic_groups_configuration.default_freeform_tags : null
11+
freeform_tags = merge(local.cislz_module_tag, each.value.freeform_tags != null ? each.value.freeform_tags : var.dynamic_groups_configuration.default_freeform_tags != null ? var.dynamic_groups_configuration.default_freeform_tags : null)
1212
}

0 commit comments

Comments
 (0)