Skip to content

Commit 2d5b1c4

Browse files
authored
Reserved IP addresses (#19)
Added the possibility to use a Reserved IP address
1 parent 5a5694b commit 2d5b1c4

9 files changed

+105
-68
lines changed

datasources.tf

+8-3
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ data "template_file" "oci_deploy_config" {
7171

7272
data "template_file" "deploy_script" {
7373
depends_on = [
74-
oci_load_balancer.flexible_loadbalancer,
74+
oci_load_balancer_load_balancer.flexible_loadbalancer,
7575
oci_container_instances_container_instance.app_container_instance
7676
]
7777
template = "${file("${path.module}/deploy.sh.template")}"
7878
vars = {
7979
"backend_name" = "${oci_container_instances_container_instance.app_container_instance[count.index].vnics[0].private_ip}:${var.exposed_port}"
8080
"backend_set_name" = "${var.application_name}_bset"
81-
"load_balancer_id" = oci_load_balancer.flexible_loadbalancer.id
81+
"load_balancer_id" = oci_load_balancer_load_balancer.flexible_loadbalancer.id
8282
"container_instance_id" = oci_container_instances_container_instance.app_container_instance[count.index].id
8383
}
8484
count = var.nb_copies
@@ -154,4 +154,9 @@ data "oci_core_subnet" "db_subnet" {
154154

155155
data "oci_core_subnet" "lb_subnet" {
156156
subnet_id = local.lb_subnet_id
157-
}
157+
}
158+
159+
data "oci_core_public_ip" "reserved_ip" {
160+
ip_address = var.reserved_ip_address == "" ? "127.0.0.1" : var.reserved_ip_address
161+
count = var.use_reserved_ip_address ? 1 : 0
162+
}

interface.yaml

+66-54
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ variableGroups:
2727
variables:
2828
- compartment_id
2929
- availability_domain
30-
###APPLICATION_GROUP###
30+
###APPLICATION_GROUP###
3131
- title: "Stack authentication"
3232
variables:
3333
- use_existing_vault
@@ -50,7 +50,7 @@ variableGroups:
5050
- autonomous_database
5151
- autonomous_database_user
5252
- autonomous_database_password
53-
###APP_CONFIG_GROUP###
53+
###APP_CONFIG_GROUP###
5454
- title: "Application URL"
5555
variables:
5656
- create_fqdn
@@ -74,6 +74,8 @@ variableGroups:
7474
- existing_lb_subnet_id
7575
- lb_subnet_cidr
7676
- open_https_port
77+
- use_reserved_ip_address
78+
- reserved_ip_address
7779
- use_default_lb_configuration
7880
- maximum_bandwidth_in_mbps
7981
- minimum_bandwidth_in_mbps
@@ -104,7 +106,7 @@ variables:
104106
dependsOn:
105107
compartmentId: ${compartment_id}
106108
# Application
107-
###APPLICATION###
109+
###APPLICATION###
108110
# APM
109111
is_free_tier:
110112
type: boolean
@@ -123,7 +125,7 @@ variables:
123125
required: true
124126
title: Autonomous Database display name
125127
description: A user-friendly name to help you easily identify the resource.
126-
visible:
128+
visible:
127129
not:
128130
- use_existing_database
129131
autonomous_database_admin_password:
@@ -132,17 +134,17 @@ variables:
132134
# validate
133135
description: Password must be 12 to 30 characters and contain at least one uppercase letter, one lowercase letter, and one number. The password cannot contain the double quote (") character or the username "admin".
134136
required: true
135-
136-
visible:
137-
not:
137+
138+
visible:
139+
not:
138140
- use_existing_database
139141
data_storage_size_in_tbs:
140142
type: number
141143
required: true
142144
title: Storage (TB)
143145
description: The amount of storage to allocate.
144146
default: 1
145-
visible:
147+
visible:
146148
not:
147149
- use_existing_database
148150
# cpu_core_count:
@@ -151,7 +153,7 @@ variables:
151153
# title: CPU core count
152154
# description: The number of OCPU cores to be made available to the database
153155
# default: 2
154-
# visible:
156+
# visible:
155157
# not:
156158
# - use_existing_database
157159
ocpu_count:
@@ -160,7 +162,7 @@ variables:
160162
title: OCPU count
161163
description: The number of OCPU cores to enable. Available cores are subject to your tenancy's service limits.
162164
default: 1
163-
visible:
165+
visible:
164166
not:
165167
- use_existing_database
166168
db_compartment:
@@ -169,35 +171,35 @@ variables:
169171
title: Autonomous Database compartment
170172
description: The compartment conataining the Autonomous Database.
171173
default: ${compartment_id}
172-
visible:
173-
and:
174-
- use_existing_database
174+
visible:
175+
and:
176+
- use_existing_database
175177
autonomous_database:
176178
type: oci:database:autonomousdatabase:id
177179
required: true
178180
title: Autonomous Database
179181
description: The Autonomous Database used by the application.
180182
dependsOn:
181183
compartmentId: ${db_compartment}
182-
visible:
183-
and:
184+
visible:
185+
and:
184186
- use_existing_database
185187
autonomous_database_user:
186188
type: string
187189
required: true
188190
title: DB username
189191
default: ""
190192
description: The username used to connect to the database.
191-
visible:
192-
and:
193+
visible:
194+
and:
193195
- use_existing_database
194196
autonomous_database_password:
195197
type: password
196198
title: DB user password
197199
required: true
198200
description: The password of the user used to access the database.
199-
visible:
200-
and:
201+
visible:
202+
and:
201203
- use_existing_database
202204
# Vault
203205
use_existing_vault:
@@ -213,7 +215,7 @@ variables:
213215
required: true
214216
visible:
215217
not:
216-
- use_existing_vault
218+
- use_existing_vault
217219
vault_compartment_id:
218220
type: oci:identity:compartment:id
219221
required: true
@@ -244,13 +246,13 @@ variables:
244246
visible:
245247
and:
246248
- use_existing_vault
247-
###APP_CONFIG###
249+
###APP_CONFIG###
248250
# FQDN
249251
create_fqdn:
250-
type : boolean
252+
type: boolean
251253
required: true
252254
default: true
253-
title : Create DNS record
255+
title: Create DNS record
254256
description: If you check this checkbox the stack will create a DNS record that will resolve to the load balancer's IP address.
255257
dns_compartment:
256258
type: oci:identity:compartment:id
@@ -259,24 +261,24 @@ variables:
259261
title: DNS and Certificate compartement
260262
description: Compartment containing the DNS Zone and the Certificate
261263
visible: create_fqdn
262-
zone :
264+
zone:
263265
type: string
264266
required: true
265267
title: DNS Zone
266-
description : Domain name in which the host name will be created.
267-
visible : create_fqdn
268+
description: Domain name in which the host name will be created.
269+
visible: create_fqdn
268270
subdomain:
269271
type: string
270272
required: true
271273
title: Host name
272274
description: The host name will be created on the selected Zone and will resolve to the the load balancer's IP address.
273-
visible : create_fqdn
275+
visible: create_fqdn
274276
certificate_ocid:
275277
type: string
276278
required: true
277279
title: Certificate OCID
278280
description: You must have a SSL certificate available in OCI Certificates service. Provide the certificate OCID for the host name.
279-
visible : create_fqdn
281+
visible: create_fqdn
280282
# Network
281283
create_new_vcn:
282284
type: boolean
@@ -288,14 +290,14 @@ variables:
288290
required: true
289291
title: The compartment of the existing VCN.
290292
default: compartment_ocid
291-
visible:
293+
visible:
292294
not:
293295
- create_new_vcn
294296
existing_vcn_id:
295297
type: oci:core:vcn:id
296298
required: true
297299
title: Select to VCN
298-
visible:
300+
visible:
299301
not:
300302
- create_new_vcn
301303
dependsOn:
@@ -313,8 +315,8 @@ variables:
313315
required: true
314316
title: Use existing Application Subnet
315317
default: false
316-
visible:
317-
not :
318+
visible:
319+
not:
318320
- create_new_vcn
319321
existing_app_subnet_id:
320322
type: oci:core:subnet:id
@@ -341,11 +343,11 @@ variables:
341343
title: Use existing Database Subnet
342344
default: false
343345
visible:
344-
and:
345-
- not:
346-
- create_new_vcn
346+
and:
347+
- not:
348+
- create_new_vcn
347349
- not:
348-
- use_existing_database
350+
- use_existing_database
349351
existing_db_subnet_id:
350352
type: oci:core:subnet:id
351353
required: true
@@ -358,23 +360,23 @@ variables:
358360
db_subnet_cidr:
359361
type: string
360362
required: true
361-
title: 'Database Subnet Creation: IPv4 CIDR Blocks'
362-
description: 'The Autonomous Database will be created in this subnet. For example: 10.0.0.128/26'
363+
title: "Database Subnet Creation: IPv4 CIDR Blocks"
364+
description: "The Autonomous Database will be created in this subnet. For example: 10.0.0.128/26"
363365
default: "10.0.0.128/26"
364366
pattern: "^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\/(3[0-2]|[1-2]?[0-9])$"
365-
visible:
367+
visible:
366368
and:
367-
- not:
368-
- use_existing_db_subnet
369369
- not:
370-
- use_existing_database
370+
- use_existing_db_subnet
371+
- not:
372+
- use_existing_database
371373
use_existing_lb_subnet:
372374
type: boolean
373375
required: true
374376
title: Use existing Load Balancer Subnet
375377
default: false
376-
visible:
377-
not :
378+
visible:
379+
not:
378380
- create_new_vcn
379381
existing_lb_subnet_id:
380382
type: oci:core:subnet:id
@@ -392,17 +394,31 @@ variables:
392394
description: The load balancer will be created in this subnet.
393395
pattern: "^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\/(3[0-2]|[1-2]?[0-9])$"
394396
default: "10.0.0.192/26"
395-
visible:
397+
visible:
396398
not:
397399
- use_existing_lb_subnet
398400
open_https_port:
399401
type: boolean
400402
required: true
401403
title: Open load balancer's HTTPS port
402-
description: By checking this checkbox you agree to make the load balancer
403-
subnet public and to open the HTTPS port of the load balancer to the
404+
description: By checking this checkbox you agree to make the load balancer
405+
subnet public and to open the HTTPS port of the load balancer to the
404406
Internet.
405407
default: false
408+
use_reserved_ip_address:
409+
type: boolean
410+
required: true
411+
title: Use a reserved IP address
412+
visible: open_https_port
413+
reserved_ip_address:
414+
type: string
415+
required: true
416+
title: Reserved IP address
417+
description: Pre-created public IP that will be used as the IP of this load balancer. This reserved IP will not be deleted when load balancer is deleted. This ip should not be already mapped to any other resource.
418+
visible:
419+
and:
420+
- open_https_port
421+
- use_reserved_ip_address
406422
# Container instances configuration
407423
shape:
408424
type: enum
@@ -439,7 +455,7 @@ variables:
439455
type: number
440456
required: true
441457
title: Maximum bandwidth (Mbps)
442-
description : 10Mbps for always free load balancer
458+
description: 10Mbps for always free load balancer
443459
default: 10
444460
visible:
445461
not:
@@ -448,7 +464,7 @@ variables:
448464
type: number
449465
required: true
450466
title: Minimum bandwidth (Mbps)
451-
description : 10Mbps for always free load balancer
467+
description: 10Mbps for always free load balancer
452468
default: 10
453469
visible:
454470
not:
@@ -476,7 +492,7 @@ variables:
476492
required: true
477493
default: false
478494
title: Enable cookie-based session persistence
479-
visible:
495+
visible:
480496
not: use_default_lb_configuration
481497
session_affinity:
482498
type: enum
@@ -505,7 +521,3 @@ outputs:
505521
type: link
506522
title: Application URL
507523
visible: true
508-
509-
510-
511-

0 commit comments

Comments
 (0)