File tree Expand file tree Collapse file tree 7 files changed +25
-5
lines changed
Expand file tree Collapse file tree 7 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ resource "oci_containerengine_cluster" "mtdrworkshop_cluster" {
99 subnet_id = oci_core_subnet. endpoint . id
1010 }
1111 kubernetes_version = " v1.25.4"
12- name = " mtdrworkshopcluster"
12+ name = " mtdrworkshopcluster- ${ var . mtdrKey } "
1313 vcn_id = oci_core_vcn. okevcn . id
1414 # optional
1515
Original file line number Diff line number Diff line change 22resource "oci_core_vcn" "okevcn" {
33 cidr_block = " 10.0.0.0/16"
44 compartment_id = var. ociCompartmentOcid
5- display_name = " mtdrworkshop"
5+ display_name = " mtdrworkshop- ${ var . mtdrKey } "
66 dns_label = " mtdrworkshop"
77}
88resource "oci_core_internet_gateway" "igw" {
Original file line number Diff line number Diff line change @@ -5,4 +5,7 @@ variable "ociUserOcid" {}
55variable "ociCompartmentOcid" {}
66variable "ociRegionIdentifier" {}
77variable "mtdrDbName" {}
8- variable "runName" {}
8+ variable "runName" {}
9+
10+ # mtdrKey is a unique generated id
11+ variable "mtdrKey" {}
Original file line number Diff line number Diff line change 11resource "oci_artifacts_container_repository" todolist {
22 # Required
33 compartment_id = var. ociCompartmentOcid
4- display_name = " ${ var . runName } /todolistapp-springboot"
4+ display_name = " ${ var . runName } /${ var . mtdrKey } / todolistapp-springboot"
55 is_public = true
66}
Original file line number Diff line number Diff line change @@ -67,6 +67,11 @@ while ! state_done USER_NAME; do
6767 state_set USER_NAME " $USER_NAME "
6868done
6969
70+ # Generate Unique Key
71+ while ! state_done MTDR_KEY; do
72+ state_set MTDR_KEY $( python " $MTDRWORKSHOP_LOCATION /utils/python-scripts/generate-unique-key.py" )
73+ done
74+
7075
7176# Get Run Name from directory name
7277while ! state_done RUN_NAME; do
@@ -178,7 +183,7 @@ while ! state_done DOCKER_REGISTRY; do
178183 while test $RETRIES -le 30; do
179184 if echo " $TOKEN " | docker login -u " $( state_get NAMESPACE) /$( state_get USER_NAME) " --password-stdin " $( state_get REGION) .ocir.io" & > /dev/null; then
180185 echo " Docker login completed"
181- state_set DOCKER_REGISTRY " $( state_get REGION) .ocir.io/$( state_get NAMESPACE) /$( state_get RUN_NAME) "
186+ state_set DOCKER_REGISTRY " $( state_get REGION) .ocir.io/$( state_get NAMESPACE) /$( state_get RUN_NAME) / $( state_get MTDR_KEY ) "
182187 export OCI_CLI_PROFILE=$( state_get REGION)
183188 break
184189 else
Original file line number Diff line number Diff line change 1+ import random
2+ import string
3+
4+ def get_random_key (length ):
5+ letters = string .ascii_lowercase
6+ digits = string .digits
7+ length = length
8+ result_str = '' .join (random .choice (letters + digits ) for i in range (length ))
9+ print (result_str )
10+
11+ get_random_key (5 )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ if ! state_done PROVISIONING; then
1414 export TF_VAR_ociRegionIdentifier=" $( state_get REGION) "
1515 export TF_VAR_runName=" $( state_get RUN_NAME) "
1616 export TF_VAR_mtdrDbName=" $( state_get MTDR_DB_NAME) "
17+ export TF_VAR_mtdrKey=" $( state_get MTDR_KEY) "
1718 # export TF_VAR_inventoryDbName="$(state_get INVENTORY_DB_NAME)"
1819
1920 if state_done K8S_PROVISIONING; then
You can’t perform that action at this time.
0 commit comments