Skip to content

Commit f756f24

Browse files
authored
refactor!: Upgrade minimum version to Terraform 1.0.0 (#33)
* refactor!: renamed operator_enabled to create_operator; minimum Terraform version is 1.0.0 BREAKING CHANGE: refactor to rename variable operator enabled to create_operator and set minimum Terraform version to 1.0.0 * removed unused security list
1 parent 32244a8 commit f756f24

16 files changed

+113
-58
lines changed

CHANGELOG.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ The format is based on {uri-changelog}[Keep a Changelog].
1010
= Unreleased
1111

1212
== New features
13+
* Set minimum Terraform version to 1.0.0
14+
* Renamed var.operator_enabled --> var.create_operator
1315
* New variable (`operator_state`) to specify state of operator host
16+
* Removed security list and using NSG instead
1417

1518
== Changes
1619
* Set default shape to E4.Flex

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019, 2020 Oracle and/or its affiliates.
1+
Copyright (c) 2019, 2021 Oracle and/or its affiliates.
22

33
The Universal Permissive License (UPL), Version 1.0
44

cloudinit/operator.template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017, 2019, Oracle Corporation and/or affiliates. All rights reserved.
1+
# 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

44
#cloud-config

compute.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017, 2019, Oracle Corporation and/or affiliates. All rights reserved.
1+
# 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

44
resource "oci_core_instance" "operator" {
@@ -12,11 +12,11 @@ resource "oci_core_instance" "operator" {
1212
freeform_tags = var.tags
1313

1414
create_vnic_details {
15-
assign_public_ip = false
16-
display_name = var.label_prefix == "none" ? "operator-vnic" : "${var.label_prefix}-operator-vnic"
17-
hostname_label = var.label_prefix == "none" ? "operator" : "${var.label_prefix}-operator"
18-
nsg_ids = var.nsg_ids
19-
subnet_id = oci_core_subnet.operator[0].id
15+
assign_public_ip = false
16+
display_name = var.label_prefix == "none" ? "operator-vnic" : "${var.label_prefix}-operator-vnic"
17+
hostname_label = var.label_prefix == "none" ? "operator" : "${var.label_prefix}-operator"
18+
nsg_ids = concat(var.nsg_ids,[oci_core_network_security_group.operator[0].id])
19+
subnet_id = oci_core_subnet.operator[0].id
2020
}
2121

2222
display_name = var.label_prefix == "none" ? "operator" : "${var.label_prefix}-operator"
@@ -25,7 +25,7 @@ resource "oci_core_instance" "operator" {
2525
boot_volume_type = "PARAVIRTUALIZED"
2626
network_type = "PARAVIRTUALIZED"
2727
}
28-
28+
2929
# prevent the operator from destroying and recreating itself if the image ocid changes
3030
lifecycle {
3131
ignore_changes = [source_details[0].source_id]
@@ -36,10 +36,10 @@ resource "oci_core_instance" "operator" {
3636
user_data = data.template_cloudinit_config.operator[0].rendered
3737
}
3838

39-
shape = lookup(var.operator_shape, "shape", "VM.Standard.E2.2")
39+
shape = lookup(var.operator_shape, "shape", "VM.Standard.E4.Flex")
4040

4141
dynamic "shape_config" {
42-
for_each = length(regexall("Flex", lookup(var.operator_shape, "shape", "VM.Standard.E3.Flex"))) > 0 ? [1] : []
42+
for_each = length(regexall("Flex", lookup(var.operator_shape, "shape", "VM.Standard.E4.Flex"))) > 0 ? [1] : []
4343
content {
4444
ocpus = max(1, lookup(var.operator_shape, "ocpus", 1))
4545
memory_in_gbs = (lookup(var.operator_shape, "memory", 4) / lookup(var.operator_shape, "ocpus", 1)) > 64 ? (lookup(var.operator_shape, "ocpus", 1) * 4) : lookup(var.operator_shape, "memory", 4)
@@ -57,5 +57,5 @@ resource "oci_core_instance" "operator" {
5757
create = "60m"
5858
}
5959

60-
count = var.operator_enabled == true ? 1 : 0
60+
count = var.create_operator == true ? 1 : 0
6161
}

datasources.tf

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
# Copyright 2017, 2019, Oracle Corporation and/or affiliates. All rights reserved.
1+
# 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+
data "oci_core_services" "all_oci_services" {
5+
filter {
6+
name = "name"
7+
values = ["All .* Services In Oracle Services Network"]
8+
regex = true
9+
}
10+
}
11+
412
data "oci_identity_availability_domains" "ad_list" {
513
compartment_id = var.tenancy_id
614
}
@@ -33,7 +41,7 @@ data "template_file" "oracle_template" {
3341
ol = var.operating_system_version
3442
}
3543

36-
count = (var.operator_enabled == true) ? 1 : 0
44+
count = (var.create_operator == true) ? 1 : 0
3745
}
3846

3947
data "template_file" "oracle_cloud_init_file" {
@@ -45,15 +53,17 @@ data "template_file" "oracle_cloud_init_file" {
4553
timezone = var.timezone
4654
}
4755

48-
count = (var.operator_enabled == true) ? 1 : 0
56+
count = (var.create_operator == true) ? 1 : 0
4957
}
5058

5159
data "oci_core_images" "oracle_images" {
5260
compartment_id = var.compartment_id
5361
operating_system = "Oracle Linux"
5462
operating_system_version = var.operating_system_version
55-
shape = lookup(var.operator_shape, "shape", "VM.Standard.E2.2")
63+
shape = lookup(var.operator_shape, "shape", "VM.Standard.E4.Flex")
5664
sort_by = "TIMECREATED"
65+
66+
count = (var.create_operator == true && var.operator_image_id == "Oracle") ? 1 : 0
5767
}
5868

5969
# cloud init for operator
@@ -66,7 +76,7 @@ data "template_cloudinit_config" "operator" {
6676
content_type = "text/cloud-config"
6777
content = data.template_file.oracle_cloud_init_file[0].rendered
6878
}
69-
count = var.operator_enabled == true ? 1 : 0
79+
count = var.create_operator == true ? 1 : 0
7080
}
7181

7282
# Gets a list of VNIC attachments on the operator instance
@@ -76,20 +86,20 @@ data "oci_core_vnic_attachments" "operator_vnics_attachments" {
7686
depends_on = [oci_core_instance.operator]
7787
instance_id = oci_core_instance.operator[0].id
7888

79-
count = var.operator_enabled == true ? 1 : 0
89+
count = var.create_operator == true ? 1 : 0
8090
}
8191

8292
# Gets the OCID of the first (default) VNIC on the operator instance
8393
data "oci_core_vnic" "operator_vnic" {
8494
depends_on = [oci_core_instance.operator]
8595
vnic_id = lookup(data.oci_core_vnic_attachments.operator_vnics_attachments[0].vnic_attachments[0], "vnic_id")
8696

87-
count = var.operator_enabled == true ? 1 : 0
97+
count = var.create_operator == true ? 1 : 0
8898
}
8999

90100
data "oci_core_instance" "operator" {
91101
depends_on = [oci_core_instance.operator]
92102
instance_id = oci_core_instance.operator[0].id
93103

94-
count = var.operator_enabled == true ? 1 : 0
104+
count = var.create_operator == true ? 1 : 0
95105
}

docs/quickstart.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ provider "oci" {
7676
* `nat_route_id`
7777
* `vcn_id`
7878
* 1 of `ssh_public_key` or `ssh_public_key_path`
79-
* `operator_enabled`
79+
* `create_operator`
8080

8181
. Optional parameters to override:
8282

docs/terraformoptions.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
128128
|Values
129129
|Default
130130

131-
|`operator_enabled`
131+
|`create_operator`
132132
|whether to create the operator
133133
| true/false
134134
|true

instance_principal.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017, 2019, Oracle Corporation and/or affiliates. All rights reserved.
1+
# 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

44
# create a home region provider for identity operations
@@ -24,7 +24,7 @@ resource "oci_identity_dynamic_group" "operator_instance_principal" {
2424
matching_rule = "ALL {instance.id = '${join(",", data.oci_core_instance.operator.*.id)}'}"
2525
name = var.label_prefix == "none" ? "operator-instance-principal-${substr(uuid(),0,8)}" : "${var.label_prefix}-operator-instance-principal-${substr(uuid(),0,8)}"
2626

27-
count = var.operator_enabled == true && var.operator_instance_principal == true ? 1 : 0
27+
count = var.create_operator == true && var.operator_instance_principal == true ? 1 : 0
2828
}
2929

3030
resource "oci_identity_policy" "operator_instance_principal" {
@@ -35,5 +35,5 @@ resource "oci_identity_policy" "operator_instance_principal" {
3535
name = var.label_prefix == "none" ? "operator-instance-principal" : "${var.label_prefix}-operator-instance-principal"
3636
statements = ["Allow dynamic-group ${oci_identity_dynamic_group.operator_instance_principal[0].name} to manage all-resources in compartment id ${var.compartment_id}"]
3737

38-
count = var.operator_enabled == true && var.operator_instance_principal == true ? 1 : 0
38+
count = var.create_operator == true && var.operator_instance_principal == true ? 1 : 0
3939
}

locals.tf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
# Copyright 2017, 2019, Oracle Corporation and/or affiliates. All rights reserved.
1+
# 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

44
# Protocols are specified as protocol numbers.
55
# https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
66

77
locals {
8-
all_protocols = "all"
9-
ad_names = data.template_file.ad_names.*.rendered
10-
anywhere = "0.0.0.0/0"
11-
ssh_port = 22
12-
tcp_protocol = 6
13-
operator_image_id = var.operator_image_id == "Oracle" ? data.oci_core_images.oracle_images.images.0.id : var.operator_image_id
14-
vcn_cidr = data.oci_core_vcn.vcn.cidr_block
8+
all_protocols = "all"
9+
ad_names = data.template_file.ad_names.*.rendered
10+
anywhere = "0.0.0.0/0"
11+
ssh_port = 22
12+
tcp_protocol = 6
13+
operator_image_id = var.operator_image_id == "Oracle" ? data.oci_core_images.oracle_images[0].images.0.id : var.operator_image_id
14+
osn = lookup(data.oci_core_services.all_oci_services.services[0], "cidr_block")
15+
vcn_cidr = data.oci_core_vcn.vcn.cidr_block
1516
}

outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Copyright 2017, 2019, Oracle Corporation and/or affiliates. All rights reserved.
1+
# 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

44
output "operator_private_ip" {
55
value = join(",", data.oci_core_vnic.operator_vnic.*.private_ip_address)
66
}
77

88
output "operator_instance_principal_group_name" {
9-
value = var.operator_enabled == true && var.operator_instance_principal == true ? oci_identity_dynamic_group.operator_instance_principal[0].name : null
9+
value = var.create_operator == true && var.operator_instance_principal == true ? oci_identity_dynamic_group.operator_instance_principal[0].name : null
1010
}

0 commit comments

Comments
 (0)