Skip to content

Commit 2ae4e51

Browse files
authored
renamed operator_instance_principal variable (#51)
Signed-off-by: Ali Mukadam <[email protected]>
1 parent ee7601c commit 2ae4e51

File tree

10 files changed

+146
-24
lines changed

10 files changed

+146
-24
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The format is based on {uri-changelog}[Keep a Changelog].
1616
* Renamed variable operating_system_version --> operator_os_version
1717
* Renamed variable operator_upgrade --> upgrade_operator
1818
* Renamed variable timezone --> operator_timezone
19+
* Renamed variable operator_instance_principal --> enable_operator_instance_principal
1920
* Added support for Bastion service
2021
* AD lookup mechanism reimplemented to remove dependency on deprecated template_file data source
2122
* Replaced deprecated template_file data source with templatefile function

docs/codingconventions.adoc

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
= Coding conventions
2+
ifdef::env-github[]
3+
:tip-caption: :bulb:
4+
:note-caption: :information_source:
5+
:important-caption: :heavy_exclamation_mark:
6+
:caution-caption: :fire:
7+
:warning-caption: :warning:
8+
endif::[]
9+
:sectnums:
10+
:toc:
11+
12+
:uri-terraform-standard-module-structure: https://www.terraform.io/docs/language/modules/develop/structure.html
13+
14+
This is a list of coding conventions you should observe when contributing code for this project.
15+
16+
Current conventions:
17+
18+
- module structure
19+
- adopting the right case type
20+
- good names for files and terraform objects (resources, variables, outputs)
21+
22+
It is not an exhaustive list and it will be updated as we go. In the mean time, your PR reviewer may suggest conventions that are not listed here.
23+
24+
Use PR comments and the GitHub suggestion feature to agree on the final result.
25+
26+
== Module Structure
27+
28+
- We adhere to the {uri-terraform-standard-module-structure}[Terraform Standard Module Structure]
29+
- Any nested module calls should be in the main file: `main.tf` is the primary entrypoint of the module
30+
- All variables and ouputs declarations should be in `variables.tf` and `outputs.tf`
31+
- All variables and outputs should have descriptions
32+
- Nested modules should exist under the `modules/` folder
33+
- Examples of using the module should exist under the `examples/` folder and have a README to explain the goal and usage of the example
34+
35+
== Documentation format
36+
37+
We use https://asciidoc.org/[AsciiDoc] with the `*.adoc` file extension. The only exception is for the README files that need to be displayed on the Terraform Registry: as the Terraform Registry does not support AsciiDoc, the `README` and certain other documentation must be available in Markdown format.
38+
39+
[NOTE]
40+
====
41+
As GitHub renders AsciiDoc files using https://asciidoctor.org/[AsciiDoctor], it is the current reference regarding AsciiDoc syntax we use in the documentation.
42+
====
43+
44+
=== Internal links
45+
46+
For internal links to AsciiDoc file (repo documentation content), we use relative links with the `xref:` macro.
47+
48+
```
49+
xref:CONTRIBUTING.adoc[CONTRIBUTING]
50+
```
51+
52+
For internal links to non-AsciiDoc file (e.g: README files), we use relative links with the `link:` macro.
53+
54+
```
55+
link:examples/README.md[examples README]
56+
```
57+
58+
=== External links
59+
60+
For external links, we use https://docs.asciidoctor.org/asciidoc/latest/macros/autolinks/[autolinks].
61+
62+
[TIP]
63+
====
64+
Links that are used multiple times must be defined in the header using the `:uri-xxx:` reference format. This makes any future updates to the URI much simpler.
65+
66+
. Defining a link in the document header
67+
. Calling the reference
68+
69+
----
70+
:uri-repo: https://github.com/oracle-terraform-modules/terraform-oci-vcn
71+
72+
{uri-repo}[link caption]
73+
----
74+
75+
====
76+
77+
=== Terraform registry requirements
78+
79+
- README files must be in Markdown format
80+
- All links must use absolute path, relative links are not supported
81+
82+
== Terraform code
83+
84+
=== Case type, Files, Names
85+
86+
- Use `snake_case` when naming Terraform files, variables and resources
87+
- If you need a new .tf file for better clarity, use this naming scheme: `<resources_group>`: e.g. `subnets.tf`, `nsgs.tf`
88+
- If your variable is controlling a behaviour, use imperative style to name it: e.g. `create_internet_gateway`, `use_encryption`
89+
90+
=== Variable blocks
91+
92+
Variables should always be in the format below:
93+
94+
----
95+
variable "xyz" {
96+
default = "A default value"
97+
description: "Add (Updatable) at the begining of the description if this value do not triggers a resource recreate"
98+
type: string
99+
----
100+
101+
When defining variables:
102+
103+
. do not hesitate to insert a brief comment in the variable block if it helps to clarify your intention.
104+
. the type should always be specified. We prefer:
105+
.. string
106+
.. boolean
107+
.. number
108+
.. collection (list, set, map, tuples) of the above
109+
. if you specify a default value, it should:
110+
.. reflect a sensible default
111+
.. match the type specified
112+
.. be reflected in terraform.tfvars.example
113+
114+
WARNING: No default value for `compartment_id` or any other variables related to provider authentication in module or examples files. The user will have to explicitly set these values.
115+
116+
=== Examples
117+
118+
Examples should promote good practices as much as possible e.g. avoid creating resources in the tenancy root compartment.

docs/instanceprincipal.adoc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
= Instance Principal
2-
32
:idprefix:
43
:idseparator: -
54
:sectlinks:
5+
:sectnums:
6+
:toc:
67

78
:uri-repo: https://github.com/oracle/terraform-oci-terraform-oci-operator
89

@@ -43,11 +44,11 @@ When you enable this feature, by default, the operator host has privileges to ma
4344

4445
You can also turn on and off the feature at any time without impact on the operator host.
4546

46-
To enable, set operator_instance_principal to true:
47+
To enable, set enable_operator_instance_principal to true:
4748

4849
[source,hcl]
4950
----
50-
operator_instance_principal = true
51+
enable_operator_instance_principal = true
5152
----
5253

5354
and verify:
@@ -60,11 +61,11 @@ You should be able to see a list of VCNs created in the compartment.
6061

6162
==== Disabling instance_principal on the operator host
6263

63-
To disable, set operator_instance_principal to false:
64+
To disable, set enable_operator_instance_principal to false:
6465

6566
[source, hcl]
6667
----
67-
operator_instance_principal = false
68+
enable_operator_instance_principal = false
6869
----
6970

7071
. Run terraform apply again:

docs/prerequisites.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
= Pre-requisites
2-
32
:idprefix:
43
:idseparator: -
54
:sectlinks:
5+
:sectnums:
6+
:toc:
67

78
:uri-repo: https://github.com/oracle-terraform-modules/terraform-oci-operator
89

docs/quickstart.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
= Quickstart
2-
32
:idprefix:
43
:idseparator: -
54
:sectlinks:
5+
:sectnums:
6+
:toc:
67

78
:uri-bastion: https://github.com/oracle-terraform-modules/terraform-oci-bastion
89
:uri-repo: https://github.com/oracle-terraform-modules/terraform-oci-operator
@@ -89,7 +90,7 @@ provider "oci" {
8990

9091
. Optional parameters to override:
9192

92-
* `operator_instance_principal`
93+
* `enable_operator_instance_principal`
9394
* `operator_shape`
9495
* `operator_upgrade`
9596
* `enable_operator_notification`

docs/terraformoptions.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
:idseparator: -
44
:sectlinks:
55
:sectnums:
6-
:uri-repo: https://github.com/oracle-terraform-modules/terraform-oci-operator
6+
:toc:
77

8+
:uri-repo: https://github.com/oracle-terraform-modules/terraform-oci-operator
89
:uri-rel-file-base: link:{uri-repo}/blob/main
910
:uri-rel-tree-base: link:{uri-repo}/tree/main
1011

@@ -122,7 +123,7 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
122123
|imageid/Oracle
123124
|Oracle
124125

125-
|`operator_instance_principal`
126+
|`enable_operator_instance_principal`
126127
|Whether to enable instance_principal on the operator.
127128
|true/false
128129
|false

instance_principal.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2017, 2021 Oracle Corporation and/or affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
33

4-
resource "oci_identity_dynamic_group" "operator_instance_principal" {
4+
resource "oci_identity_dynamic_group" "enable_operator_instance_principal" {
55
provider = oci.home
66

77
compartment_id = var.tenancy_id
@@ -14,16 +14,16 @@ resource "oci_identity_dynamic_group" "operator_instance_principal" {
1414
matching_rule = "ALL {instance.id = '${join(",", data.oci_core_instance.operator.*.id)}'}"
1515
name = "operator-instance-principal-${substr(uuid(), 0, 8)}"
1616

17-
count = var.operator_instance_principal == true ? 1 : 0
17+
count = var.enable_operator_instance_principal == true ? 1 : 0
1818
}
1919

20-
resource "oci_identity_policy" "operator_instance_principal" {
20+
resource "oci_identity_policy" "enable_operator_instance_principal" {
2121
provider = oci.home
2222

2323
compartment_id = var.compartment_id
2424
description = "policy to allow operator host to call services"
2525
name = var.label_prefix == "none" ? "operator-instance-principal" : "${var.label_prefix}-operator-instance-principal"
26-
statements = ["Allow dynamic-group ${oci_identity_dynamic_group.operator_instance_principal[0].name} to manage all-resources in compartment id ${var.compartment_id}"]
26+
statements = ["Allow dynamic-group ${oci_identity_dynamic_group.enable_operator_instance_principal[0].name} to manage all-resources in compartment id ${var.compartment_id}"]
2727

28-
count = var.operator_instance_principal == true ? 1 : 0
28+
count = var.enable_operator_instance_principal == true ? 1 : 0
2929
}

outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ output "operator_private_ip" {
55
value = join(",", data.oci_core_vnic.operator_vnic.*.private_ip_address)
66
}
77

8-
output "operator_instance_principal_group_name" {
9-
value = var.operator_instance_principal == true ? oci_identity_dynamic_group.operator_instance_principal[0].name : null
8+
output "enable_operator_instance_principal_group_name" {
9+
value = var.enable_operator_instance_principal == true ? oci_identity_dynamic_group.enable_operator_instance_principal[0].name : null
1010
}
1111

1212
output "operator_subnet_id" {

terraform.tfvars.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ operating_system_version = "8"
3434

3535
operator_image_id = "Oracle"
3636

37-
operator_instance_principal = true
37+
enable_operator_instance_principal = true
3838

3939
operating_os_version = "8"
4040

variables.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ variable "vcn_id" {
5959
}
6060

6161
# operator host parameters
62+
variable "enable_operator_instance_principal" {
63+
description = "whether to enable instance_principal on the operator"
64+
default = false
65+
type = bool
66+
}
6267

6368
variable "freeform_tags" {
6469
description = "Freeform tags for operator"
@@ -76,12 +81,6 @@ variable "operator_image_id" {
7681
type = string
7782
}
7883

79-
variable "operator_instance_principal" {
80-
description = "whether to enable instance_principal on the operator"
81-
default = false
82-
type = bool
83-
}
84-
8584
variable "operator_os_version" {
8685
description = "The version of the Oracle Linux to use."
8786
default = "8"

0 commit comments

Comments
 (0)