Skip to content

Commit 515d6a8

Browse files
authored
Merge pull request #39 from hyder/issue-38
formatting, variables and output descriptions, updated docs
2 parents 64740e1 + b6bdbdc commit 515d6a8

23 files changed

+184
-141
lines changed

docs/instanceprincipal.adoc

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,20 @@ This section documents the use of {uri-oci-instance-principal}[instance_principa
3737

3838
Any user who has access to the instance (who can SSH to the instance), automatically inherits the privileges granted to the instance. Before you enable this feature, ensure that you know who can access it, and that they should be authorized with the permissions you are granting to the instance.
3939

40-
By default, this feature is *_enabled_*.
40+
By default, this feature is *_disabled_*.
4141

42-
When you enable this feature, by default, the admin host has privileges to all resources in the compartment.
42+
When you enable this feature, by default, the admin host has privileges to manage all resources in the compartment.
4343

4444
You can also turn on and off the feature at any time without impact on the admin host.
4545

46-
To enable, set enable_instance_principal to true:
46+
To enable, set enable_instance_principal in oci_base_admin to true:
4747

4848
----
49-
enable_instance_principal = "true"
49+
oci_base_admin = {
50+
....
51+
enable_instance_principal = true
52+
....
53+
}
5054
----
5155

5256
and verify:
@@ -55,13 +59,19 @@ and verify:
5559
oci network vcn list --compartment-id <compartment-ocid>
5660
----
5761

62+
You should be able to see a list of VCNs created in the compartment.
63+
5864
==== Disabling instance_principal on the admin host
5965

60-
. Set enable_instance_principal to false in terraform.tfvars
66+
To disable, set enable_instance_principal in oci_base_admin to false:
6167

6268
+
6369
----
64-
enable_instance_principal = false
70+
oci_base_admin = {
71+
....
72+
enable_instance_principal = false
73+
....
74+
}
6575
----
6676

6777
. Run terraform apply again:

docs/notifications.adoc

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ The {uri-oci-notifications}[Oracle Cloud Infrastructure Notifications service] c
3232
Set the following parameters in the terraform.tfvars in order to enable ONS Notification for the bastion host:
3333

3434
----
35-
notification_enabled = true
36-
notification_endpoint = "email_address"
37-
notification_protocol = "EMAIL"
38-
notification_topic = "bastion"
35+
oci_base_bastion = {
36+
...
37+
notification_enabled = true
38+
notification_endpoint = "valid_email_address"
39+
notification_protocol = "EMAIL"
40+
notification_topic = "bastion"
41+
...
42+
}
3943
----
4044

4145
If your bastion is already created, set the above parameters in the terraform.tfvars and run terraform apply again:
@@ -46,26 +50,16 @@ terraform apply
4650

4751
You'll then receive a notification email to confirm the subscription.
4852

49-
Note that at the time of enabling ONS notification, instance_principal for the bastion must be enabled by setting *enable_instance_principal* to _true_. This can subsequently be disabled by setting it to _false_:
50-
51-
----
52-
enable_instance_principal = false
53-
----
54-
55-
and running terraform apply again:
56-
57-
----
58-
terraform apply
59-
----
60-
61-
Read more on {uri-instance-principal}[instance_principal].
62-
6353
==== Disabling ONS Notification for the bastion host
6454

6555
Set the following parameters in the terraform.tfvars to disable ONS Notification:
6656

6757
----
68-
notification_enabled = false
58+
oci_base_bastion = {
59+
...
60+
notification_enabled = false
61+
...
62+
}
6963
----
7064

7165
and run terraform apply again:

docs/terraformoptions.adoc

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ Configuration Terraform Options:
6969
|Default
7070

7171
|label_prefix
72-
|a string to be prepended to the name of resources.
72+
|a string to be prepended to the name of resources. *Recommended*
73+
|
7374
|
74-
|base
7575

7676
|region
7777
|Region where to provision the resources. {uri-oci-region}[List of regions]. *Required*
@@ -97,22 +97,22 @@ Configuration Terraform Options:
9797
|service_gateway_enabled
9898
|Whether to create a Service Gateway to use Oracle Services.
9999
|true/false
100-
|false
100+
|true
101101

102102
|vcn_cidr
103103
|The VCN's CIDR block.
104104
|
105105
|10.0.0.0/16
106106

107107
|vcn_dns_label
108-
|The internal DNS domain for resources created and prepended to "oraclevcn.com" which is the VCN-internal domain name.
108+
|The internal DNS domain for resources created and prepended to "oraclevcn.com" which is the VCN-internal domain name. *Required*
109+
|
109110
|
110-
|base
111111

112-
|vcn_name
113-
|The name of the VCN that will be appended to the label_prefix.
112+
|vcn_name.
113+
|The name of the VCN that will be appended to the label_prefix. *Recommended*
114+
|
114115
|
115-
|base
116116

117117
|===
118118

@@ -145,28 +145,23 @@ Configuration Terraform Options:
145145
|bastion_enabled
146146
|Whether to create the bastion host.
147147
|true/false
148-
|true
148+
|false
149149

150150
|bastion_image_id
151-
|Custom image id for the bastion host
151+
|Provide a custom image id for the bastion host or leave as Autonomous.
152152
|imageid/Autonomous
153153
|Autonomous
154154

155155
|bastion_shape
156-
|The shape of bastion instance.
156+
|The shape of bastion instance. *Required if bastion_enabled = true*
157+
|
157158
|
158-
|VM.Standard.E2.1
159159

160160
|bastion_upgrade
161-
|Whether to upgrade the bastion host packages after provisioning. It's useful to set this to false during development so the bastion is provisioned faster.
161+
|Whether to upgrade the bastion host packages after provisioning. It's useful to set this to false during development/testing so the bastion is provisioned faster.
162162
|true/false
163163
|true
164164

165-
|enable_notification
166-
|Whether to enable ONS notification for the bastion host.
167-
|true/false
168-
|false
169-
170165
|newbits
171166
|The difference between the VCN's netmask and the desired subnets' masks specified in the form of a map. The values of the map are used as the newbits parameter in the {uri-terraform-cidrsubnet}[cidrsubnet] Terraform function to calculate each subnet's mask.
172167
|[source]
@@ -191,8 +186,13 @@ Configuration Terraform Options:
191186
32
192187
----
193188

189+
|notification_enabled
190+
|Whether to enable ONS notification for the bastion host.
191+
|true/false
192+
|false
193+
194194
|notification_endpoint
195-
|The subscription notification endpoint. Email address to be notified.
195+
|The subscription notification endpoint. Email address to be notified. *Required if notification_enabled = true* .
196196
|
197197
|
198198

@@ -236,7 +236,7 @@ Configuration Terraform Options:
236236
|admin_enabled
237237
|Whether to create the admin host.
238238
|true/false
239-
|true
239+
|false
240240

241241
|admin_image_id
242242
|Custom image id for the admin host
@@ -246,24 +246,24 @@ Configuration Terraform Options:
246246
|enable_instance_principal
247247
|Whether to enable instance_principal on the admin server. Refer to {uri-instance-principal-note}[instance_principal][instance_principal]
248248
|true/false
249-
|true
249+
|false
250250

251-
|admin_notification_enabled
251+
|notification_enabled
252252
|Whether to enable ONS notification for the admin host. *Do not enable for now*.
253253
|true/false
254254
|false
255255

256-
|admin_notification_endpoint
256+
|notification_endpoint
257257
|The subscription notification endpoint. Email address to be notified. Only email is currently supported although ONS can also support Slack, Pagerduty among others.
258258
|
259259
|
260260

261-
|admin_notification_protocol
261+
|notification_protocol
262262
|The notification protocol used.
263263
|EMAIL
264264
|EMAIL
265265

266-
|admin_notification_topic
266+
|notification_topic
267267
|The name of the notification topic
268268
|
269269
|admin
@@ -276,7 +276,7 @@ Configuration Terraform Options:
276276
|admin_shape
277277
|The shape of admin instance.
278278
|
279-
|VM.Standard.E2.1
279+
|
280280

281281
|admin_timezone
282282
|The preferred timezone for the admin host. {uri-timezones}[List of timezones]

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module "bastion" {
1010
source = "./modules/bastion"
1111
oci_base_identity = var.oci_base_identity
1212
oci_bastion_general = local.oci_bastion_general
13-
oci_bastion_network = local.oci_bastion_network
13+
oci_bastion_network = local.oci_bastion_network
1414
oci_bastion = local.oci_bastion
1515
oci_bastion_notification = local.oci_bastion_notification
1616
}

modules/admin/cloudinit/admin.template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ write_files:
1414
content: |
1515
${admin_sh_content}
1616
runcmd:
17-
- echo "Configuring admin..." | tee /root/admin/admin.txt
17+
- echo "Configuring admin..."
1818
- bash /root/admin/admin.sh
1919
- echo "export OCI_CLI_AUTH=instance_principal" >> /home/opc/.bashrc
2020
- touch /home/opc/admin.finish

modules/admin/compute.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ resource "oci_core_instance" "admin" {
1414

1515
display_name = "${var.oci_admin_general.label_prefix}-admin"
1616

17-
extended_metadata = {
18-
ssh_authorized_keys = file(var.oci_admin.ssh_public_key_path)
19-
user_data = data.template_cloudinit_config.admin[0].rendered
20-
subnet_id = oci_core_subnet.admin[0].id
21-
}
22-
2317
# prevent the bastion from destroying and recreating itself if the image ocid changes
2418
lifecycle {
2519
ignore_changes = [source_details[0].source_id]
2620
}
2721

22+
metadata = {
23+
ssh_authorized_keys = file(var.oci_admin.ssh_public_key_path)
24+
user_data = data.template_cloudinit_config.admin[0].rendered
25+
}
26+
2827
shape = var.oci_admin.admin_shape
2928

3029
source_details {

modules/admin/datasources.tf

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ data "oci_core_images" "admin_images" {
1111

1212
data "template_file" "admin_template" {
1313
template = file("${path.module}/scripts/admin.template.sh")
14-
count = var.oci_admin.admin_enabled == true ? 1 : 0
14+
15+
count = var.oci_admin.admin_enabled == true ? 1 : 0
1516
}
1617

1718

@@ -23,6 +24,7 @@ data "template_file" "admin_cloud_init_file" {
2324
admin_upgrade = var.oci_admin.admin_upgrade
2425
timezone = var.oci_admin.timezone
2526
}
27+
2628
count = var.oci_admin.admin_enabled == true ? 1 : 0
2729
}
2830

@@ -36,6 +38,7 @@ data "template_cloudinit_config" "admin" {
3638
content_type = "text/cloud-config"
3739
content = data.template_file.admin_cloud_init_file[0].rendered
3840
}
41+
3942
count = var.oci_admin.admin_enabled == true ? 1 : 0
4043
}
4144

@@ -44,17 +47,19 @@ data "oci_core_vnic_attachments" "admin_vnics_attachments" {
4447
availability_domain = element(var.oci_admin_network.ad_names, (var.oci_admin_network.availability_domains - 1))
4548
compartment_id = var.oci_admin_identity.compartment_id
4649
instance_id = oci_core_instance.admin[0].id
47-
count = var.oci_admin.admin_enabled == true ? 1 : 0
50+
51+
count = var.oci_admin.admin_enabled == true ? 1 : 0
4852
}
4953

5054
# Gets the OCID of the first (default) VNIC on the admin instance
5155
data "oci_core_vnic" "admin_vnic" {
5256
vnic_id = lookup(data.oci_core_vnic_attachments.admin_vnics_attachments[0].vnic_attachments[0], "vnic_id")
53-
count = var.oci_admin.admin_enabled == true ? 1 : 0
57+
58+
count = var.oci_admin.admin_enabled == true ? 1 : 0
5459
}
5560

5661
data "oci_core_instance" "admin" {
57-
#Required
5862
instance_id = oci_core_instance.admin[0].id
59-
count = var.oci_admin.admin_enabled == true ? 1 : 0
63+
64+
count = var.oci_admin.admin_enabled == true ? 1 : 0
6065
}

modules/admin/instance_principal.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,23 @@ data "oci_identity_compartments" "compartments_id" {
2323
}
2424

2525
resource "oci_identity_dynamic_group" "admin_instance_principal" {
26-
provider = oci.home
26+
provider = oci.home
27+
2728
compartment_id = var.oci_admin_identity.tenancy_id
2829
description = "dynamic group to allow instances to call services for 1 admin"
2930
matching_rule = "ALL {instance.id = '${join(",", data.oci_core_instance.admin.*.id)}'}"
3031
name = "${var.oci_admin_general.label_prefix}-admin_instance_principal"
31-
count = var.oci_admin.admin_enabled == true && var.oci_admin.enable_instance_principal == true ? 1 : 0
32+
33+
count = var.oci_admin.admin_enabled == true && var.oci_admin.enable_instance_principal == true ? 1 : 0
3234
}
3335

3436
resource "oci_identity_policy" "admin_instance_principal" {
35-
provider = oci.home
37+
provider = oci.home
38+
3639
compartment_id = var.oci_admin_identity.compartment_id
3740
description = "policy to allow admin host to call services"
3841
name = "${var.oci_admin_general.label_prefix}-admin_instance_principal"
3942
statements = ["Allow dynamic-group ${oci_identity_dynamic_group.admin_instance_principal[0].name} to manage all-resources in compartment id ${data.oci_identity_compartments.compartments_id.compartments.0.id}"]
40-
count = var.oci_admin.admin_enabled == true && var.oci_admin.enable_instance_principal == true ? 1 : 0
43+
44+
count = var.oci_admin.admin_enabled == true && var.oci_admin.enable_instance_principal == true ? 1 : 0
4145
}

modules/admin/security.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
resource "oci_core_security_list" "admin" {
55
compartment_id = var.oci_admin_identity.compartment_id
66
display_name = "${var.oci_admin_general.label_prefix}-admin"
7-
vcn_id = var.oci_admin_network.vcn_id
87

98
egress_security_rules {
109
protocol = local.all_protocols
@@ -22,5 +21,7 @@ resource "oci_core_security_list" "admin" {
2221
max = local.ssh_port
2322
}
2423
}
24+
vcn_id = var.oci_admin_network.vcn_id
25+
2526
count = var.oci_admin.admin_enabled == true ? 1 : 0
2627
}

modules/admin/subnets.tf

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

44
resource "oci_core_subnet" "admin" {
5-
compartment_id = var.oci_admin_identity.compartment_id
65
cidr_block = cidrsubnet(var.oci_admin_network.vcn_cidr, var.oci_admin_network.newbits, var.oci_admin_network.netnum)
6+
compartment_id = var.oci_admin_identity.compartment_id
77
display_name = "${var.oci_admin_general.label_prefix}-admin"
88
dns_label = "admin"
99
prohibit_public_ip_on_vnic = true

0 commit comments

Comments
 (0)