Skip to content

Commit aeced51

Browse files
authored
removed identity provider parameters (#33)
* removed identity home provider initialization from bastion module, use parameter passing instead Signed-off-by: Ali Mukadam <[email protected]> * updated changelog Signed-off-by: Ali Mukadam <[email protected]> * updated copyright Signed-off-by: Ali Mukadam <[email protected]> * fixed doc formatting, renamed tags variable Signed-off-by: Ali Mukadam <[email protected]> * renamed notification variable Signed-off-by: Ali Mukadam <[email protected]> * tags should be changed to bastion_tags in example, unused provider variables in terraform.tfvars.example ,change bastion_access = [anywhere] * fixed more examples issues Signed-off-by: Ali Mukadam <[email protected]> * fixed incorrect path to bastion root in examples Signed-off-by: Ali Mukadam <[email protected]>
1 parent 292dd9f commit aeced51

17 files changed

+140
-153
lines changed

CHANGELOG.adoc

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

1212
== New features
13-
* Renamed notification variables
14-
** create_bastion -> create_bastion_host
15-
** enable_notification -> create_bastion_notification
16-
** notification_endpoint -> bastion_notification_endpoint
17-
** notification_protocol -> bastion_notification_protocol
18-
** notification_topic -> bastion_notification_topic
19-
** Changed bastion access from a single CIDR to a list of CIDR blocks (#29)
20-
* Renamed variable bastion_upgrade --> upgrade_bastion
21-
* Renamed variable timezone --> bastion_timezone
22-
* AD lookup mechanism reimplemented to remove dependency on deprecated template_file data source
23-
* Replaced deprecated template_file data source with templatefile function
24-
* New variable (`bastion_operating_system_version`) to specify Autonomous Linux version (#15)
13+
* New variable (`bastion_os_version`) to specify Autonomous Linux version (#15)
2514
* Added sort_order on images (#16)
2615
* New variable (`bastion_state`) to specify state of bastion host (#17)
2716
* Added support for private bastion host (#23)
2817

29-
=== Deprecation notice
30-
31-
The following variables will be renamed at the next major release of this module (related to #18):
32-
33-
* var.bastion_enabled --> var.create_bastion
18+
== Changes
19+
* Set minimum Terraform version to 1.0.0
20+
* OCI home region provider now expected as parameter to providers
21+
* Renamed notification variables (#18)
22+
** create_bastion -> create_bastion_host
23+
** enable_notification -> enable_bastion_notification
24+
** notification_endpoint -> bastion_notification_endpoint
25+
** notification_protocol -> bastion_notification_protocol
26+
** notification_topic -> bastion_notification_topic
27+
** Renamed variable bastion_upgrade --> upgrade_bastion
28+
** Renamed variable timezone --> bastion_timezone
29+
** Renamed variable tags --> bastion_tags
30+
* Changed bastion access from a single CIDR to a list of CIDR blocks (#29)
31+
* AD lookup mechanism reimplemented to remove dependency on deprecated template_file data source (#27)
32+
* Replaced all deprecated template_file data source with templatefile function (#27)
33+
34+
== Deletion
35+
* Removed provider identity parameters except for tenancy_id
3436

3537
= v2.0.0 (December 8, 2020)
3638
* Added support for flex shapes (#11)

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

compute.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
resource "oci_core_instance" "bastion" {
55
availability_domain = data.oci_identity_availability_domain.ad.name
66
compartment_id = var.compartment_id
7-
freeform_tags = var.tags
7+
freeform_tags = var.bastion_tags
88

99
agent_config {
1010

datasources.tf

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,17 @@
33

44
data "oci_identity_availability_domain" "ad" {
55
compartment_id = var.tenancy_id
6-
76
ad_number = var.availability_domain
87
}
98

10-
data "oci_identity_tenancy" "tenancy" {
11-
tenancy_id = var.tenancy_id
12-
}
13-
14-
# get the tenancy's home region
15-
data "oci_identity_regions" "home_region" {
16-
filter {
17-
name = "key"
18-
values = [data.oci_identity_tenancy.tenancy.home_region_key]
19-
}
20-
}
21-
229
data "oci_core_vcn" "vcn" {
2310
vcn_id = var.vcn_id
2411
}
2512

2613
data "oci_core_images" "autonomous_images" {
2714
compartment_id = var.compartment_id
2815
operating_system = "Oracle Autonomous Linux"
29-
operating_system_version = var.bastion_operating_system_version
16+
operating_system_version = var.bastion_os_version
3017
shape = lookup(var.bastion_shape, "shape", "VM.Standard.E2.2")
3118
sort_by = "TIMECREATED"
3219
sort_order = "DESC"
@@ -79,5 +66,5 @@ data "oci_core_instance" "bastion" {
7966
data "oci_ons_notification_topic" "bastion_notification" {
8067
topic_id = oci_ons_notification_topic.bastion_notification[0].topic_id
8168

82-
count = (var.create_bastion_host == true && var.create_bastion_notification == true) ? 1 : 0
69+
count = (var.create_bastion_host == true && var.enable_bastion_notification == true) ? 1 : 0
8370
}

docs/terraformoptions.adoc

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,11 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
2929
|Values
3030
|Default
3131

32-
|`api_fingerprint`
33-
|ssl fingerprint of api public key. *Required when configuring provider*.
34-
|
35-
|None
36-
37-
|`api_private_key_path`
38-
|path to api private key. *Required when configuring provider*.
39-
|
40-
|None
41-
42-
|`region`
43-
|Region where to provision the OKE cluster. {uri-oci-region}[List of regions]. *Required when configuring provider*.
44-
|
45-
|None
46-
4732
|`tenancy_id`
4833
|Tenancy id of the user. *Required when configuring provider*.
4934
|
5035
|None
5136

52-
|`user_id`
53-
|User's id. *Required when configuring provider*.
54-
|
55-
|None
56-
5737
|===
5838

5939
== General OCI
@@ -94,8 +74,8 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
9474

9575
|`bastion_access`
9676
|A list of CIDR blocks to which ssh access to the bastion must be restricted to. *anywhere* is equivalent to 0.0.0.0/0 and allows ssh access from anywhere. Updatable.
97-
|["anywhere"] or a list of cidr block such as [XXX.XXX.XXX.XXX/YY]
98-
|["anywhere"]
77+
|`["anywhere"]`` or a list of cidr block such as `[XXX.XXX.XXX.XXX/YY]`
78+
|`["anywhere"]`
9979

10080
|`ig_route_id`
10181
|the route id to the internet gateway of the VCN
@@ -138,7 +118,7 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
138118
|imageid/Autonomous
139119
|Autonomous
140120

141-
|`bastion_operating_system_version`
121+
|`bastion_os_version`
142122
|In case Autonomous Linux is used, allow specification of Autonomous version
143123
|
144124
|7.9
@@ -160,7 +140,7 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
160140

161141
|`bastion_state`
162142
|The target state for the instance. Could be set to RUNNING or STOPPED. (Updatable)
163-
|RUNNING|STOPPED
143+
|RUNNING/STOPPED
164144
|RUNNING
165145

166146
|`bastion_timezone`
@@ -170,7 +150,7 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
170150

171151
|`bastion_type`
172152
|Whether to make the bastion host public or private.
173-
|public|private
153+
|public/private
174154
|public
175155

176156
|`ssh_public_key`
@@ -200,7 +180,7 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
200180
|Values
201181
|Default
202182

203-
|`create_bastion_notification`
183+
|`enable_bastion_notification`
204184
|Whether to enable ONS notification for the bastion host.
205185
|true/false
206186
|false
@@ -230,13 +210,13 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
230210
|Values
231211
|Default
232212

233-
|`tags`
213+
|`bastion_tags`
234214
|Freeform tags for bastion.
235215
|
236216
|
237217
[source]
238218
----
239-
tags = {
219+
bastion_tags = {
240220
access = "public"
241221
environment = "dev"
242222
role = "bastion"

examples/README.md

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ mkdir modules
4141
cd modules
4242
```
4343

44-
5. Add the terraform-oci-bastion module
45-
46-
```
47-
git clone https://github.com/oracle/terraform-oci-bastion.git bastion
48-
```
49-
50-
Note: Cloning will be required until the module is published in HashiCorp's registry.
51-
5244
## Define project variables
5345

5446
### Variables to reuse the vcn module
@@ -63,18 +55,57 @@ See [`variables.tf`][rootvariables] in this directory.
6355
1. Define the bastion module in root `main.tf`
6456

6557
```
66-
module "vcn" {
67-
source = "./modules/vcn"
68-
69-
# general oci parameters
58+
provider "oci" {
59+
fingerprint = var.api_fingerprint
60+
private_key_path = var.api_private_key_path
61+
region = var.region
62+
tenancy_ocid = var.tenancy_id
63+
user_ocid = var.user_id
64+
}
65+
66+
provider "oci" {
67+
fingerprint = var.api_fingerprint
68+
private_key_path = var.api_private_key_path
69+
region = var.region
70+
tenancy_ocid = var.tenancy_id
71+
user_ocid = var.user_id
72+
alias = "home"
73+
}
74+
75+
module "bastion" {
76+
source = "../"
77+
tenancy_id = var.tenancy_id
7078
compartment_id = var.compartment_id
79+
7180
label_prefix = var.label_prefix
7281
73-
# vcn parameters
74-
ig_route_id = var.ig_route_id
75-
vcn_id = var.vcn_id
76-
ssh_public_key = var.ssh_public_key
82+
availability_domain = var.availability_domain
83+
84+
ig_route_id = var.ig_route_id
85+
86+
netnum = var.netnum
87+
88+
newbits = var.newbits
89+
90+
vcn_id = var.vcn_id
91+
92+
create_bastion_host = true
93+
94+
ssh_public_key_path = "~/.ssh/id_rsa.pub"
95+
96+
upgrade_bastion = false
97+
98+
bastion_tags = {
99+
access = "public"
100+
environment = "dev"
101+
role = "bastion"
102+
}
103+
104+
providers = {
105+
oci.home = oci.home
106+
}
77107
}
108+
78109
```
79110

80111
2. Enter appropriate values for `terraform.tfvars`. Review [Terraform Options][terraformoptions] for reference

examples/main.tf

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,47 @@
1-
# Copyright (c) 2019, 2020 Oracle Corporation and/or affiliates. All rights reserved.
1+
# Copyright (c) 2019, 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+
provider "oci" {
5+
fingerprint = var.api_fingerprint
6+
private_key_path = var.api_private_key_path
7+
region = var.region
8+
tenancy_ocid = var.tenancy_id
9+
user_ocid = var.user_id
10+
}
11+
12+
provider "oci" {
13+
fingerprint = var.api_fingerprint
14+
private_key_path = var.api_private_key_path
15+
region = var.region
16+
tenancy_ocid = var.tenancy_id
17+
user_ocid = var.user_id
18+
alias = "home"
19+
}
20+
421
module "bastion" {
5-
source = "../"
22+
source = "../"
23+
tenancy_id = var.tenancy_id
24+
compartment_id = var.compartment_id
25+
26+
label_prefix = var.label_prefix
627

7-
region = "us-phoenix-1"
28+
ig_route_id = var.ig_route_id
829

9-
# general oci parameters
30+
vcn_id = var.vcn_id
1031

11-
compartment_id = ""
32+
create_bastion_host = true
1233

13-
label_prefix = "dev"
34+
ssh_public_key_path = "~/.ssh/id_rsa.pub"
1435

15-
# network parameters
16-
ig_route_id = ""
36+
upgrade_bastion = false
1737

18-
vcn_id = ""
38+
bastion_tags = {
39+
access = "public"
40+
environment = "dev"
41+
role = "bastion"
42+
}
1943

20-
ssh_public_key = ""
44+
providers = {
45+
oci.home = oci.home
46+
}
2147
}

examples/terraform.tfvars.example

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,8 @@
33

44
# provider identity parameters
55

6-
api_fingerprint = ""
7-
8-
api_private_key_path = ""
9-
10-
region = "us-phoenix-1"
11-
126
tenancy_id = ""
137

14-
user_id = ""
15-
168
# general oci parameters
179

1810
compartment_id = ""

examples/variables.tf

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

locals.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ locals {
1616
notification_template = base64gzip(
1717
templatefile("${path.module}/scripts/notification.template.sh",
1818
{
19-
create_bastion_notification = var.create_bastion_notification,
20-
topic_id = var.create_bastion_notification == true ? oci_ons_notification_topic.bastion_notification[0].topic_id : "null"
19+
enable_bastion_notification = var.enable_bastion_notification,
20+
topic_id = var.enable_bastion_notification == true ? oci_ons_notification_topic.bastion_notification[0].topic_id : "null"
2121
}
2222
)
2323
)

0 commit comments

Comments
 (0)