@@ -70,13 +70,17 @@ help:
7070 @echo " ${BLUE}${INFO} ☁️ terraform-apply${RESET} - Apply Terraform changes"
7171 @echo " ${BLUE}${INFO} ☁️ terraform-destroy${RESET} - Destroy Terraform-managed infrastructure"
7272 @echo " ${BLUE}${INFO} ☁️ terraform-output${RESET} - Generate cloud.properties from Terraform output"
73+ @echo " ${BLUE}${INFO} ☁️ terraform-upgrade${RESET} - Upgrade Terraform providers"
74+ @echo " ${BLUE}${INFO} ☁️ terraform-org-id${RESET} - Get Confluent Cloud organization ID"
7375 @echo " ${BLUE}${INFO} ☁️ cc-setup${RESET} - Complete Confluent Cloud setup (init, plan, apply, output)"
7476 @echo " ${BLUE}${INFO} ☁️ cc-teardown${RESET} - Teardown Confluent Cloud infrastructure"
7577 @echo " ${BLUE}${INFO} ☁️ tf-init${RESET} - Shorthand for terraform-init"
7678 @echo " ${BLUE}${INFO} ☁️ tf-plan${RESET} - Shorthand for terraform-plan"
7779 @echo " ${BLUE}${INFO} ☁️ tf-apply${RESET} - Shorthand for terraform-apply"
7880 @echo " ${BLUE}${INFO} ☁️ tf-destroy${RESET} - Shorthand for terraform-destroy"
7981 @echo " ${BLUE}${INFO} ☁️ tf-out${RESET} - Shorthand for terraform-output"
82+ @echo " ${BLUE}${INFO} ☁️ tf-upgrade${RESET} - Shorthand for terraform-upgrade"
83+ @echo " ${BLUE}${INFO} ☁️ tf-org-id${RESET} - Shorthand for terraform-org-id"
8084 @echo " "
8185 @echo " ${YELLOW}${STAR} Cleanup:${RESET} "
8286 @echo " ${BLUE}${INFO} 🧹 clean${RESET} - Clean up temporary files"
@@ -253,7 +257,7 @@ terraform-init:
253257 @echo " ${BLUE}${ROCKET} Initializing Terraform...${RESET} "
254258 cd terraform && terraform init
255259
256- .PHONY : terraform-update
260+ .PHONY : terraform-upgrade
257261terraform-upgrade :
258262 @echo " ${BLUE}${ROCKET} Updating Terraform...${RESET} "
259263 cd terraform && terraform init -upgrade
@@ -266,7 +270,7 @@ terraform-plan:
266270.PHONY : terraform-apply
267271terraform-apply :
268272 @echo " ${BLUE}${ROCKET} Applying Terraform changes...${RESET} "
269- cd terraform && terraform apply
273+ cd terraform && terraform apply " tfplan "
270274
271275.PHONY : terraform-destroy
272276terraform-destroy :
@@ -280,12 +284,31 @@ terraform-destroy:
280284 echo " ${YELLOW}${INFO} Operation cancelled.${RESET} " ; \
281285 fi
282286
287+ # Get Confluent Cloud organization ID
288+ .PHONY : terraform-org-id
289+ terraform-org-id :
290+ @echo " ${BLUE}${CLOUD} Getting Confluent Cloud organization ID...${RESET} "
291+ @if ! command -v confluent > /dev/null 2>&1 ; then \
292+ echo " ${RED}${ERROR} Confluent CLI is not installed. Please install it first.${RESET} " ; \
293+ exit 1; \
294+ fi
295+ @if ! command -v jq > /dev/null 2>&1 ; then \
296+ echo " ${RED}${ERROR} jq is not installed. Please install it first.${RESET} " ; \
297+ exit 1; \
298+ fi
299+ @echo " ${BLUE}${INFO} Exporting organization ID to TF_VAR_org_id...${RESET} "
300+ @export TF_VAR_org_id=$$(confluent organization list -o json | jq -c -r '.[] | select(.is_current ) ' | jq ' .id' ); \
301+ echo " TF_VAR_org_id=$$ TF_VAR_org_id" ; \
302+ echo " export TF_VAR_org_id=$$ TF_VAR_org_id" >> .env; \
303+ echo " ${GREEN}${CHECK} Organization ID exported to TF_VAR_org_id and saved to .env file!${RESET} "
304+
283305# Generate cloud.properties from Terraform output
284306.PHONY : terraform-output
285307terraform-output :
286308 @echo " ${BLUE}${CLOUD} Generating cloud.properties from Terraform output...${RESET} "
287- cd terraform && terraform output -json | jq -r ' to_entries | map( {key: .key|tostring|split("_")|join("."), value: .value} ) | map("client.\(.key)=\(.value.value)") | .[]' > ../cloud.properties
288- @echo " ${GREEN}${CHECK} cloud.properties generated!${RESET} "
309+ @mkdir -p ../common/utils/src/main/resources
310+ cd terraform && terraform output -json | jq -r ' to_entries | map( {key: .key|tostring|split("_")|join("."), value: .value} ) | map("\(.key)=\(.value.value)") | .[]' | while read -r line ; do echo " $$ line" ; done > ../common/utils/src/main/resources/cloud.properties
311+ @echo " ${GREEN}${CHECK} cloud.properties generated in ../common/utils/src/main/resources/cloud.properties!${RESET} "
289312
290313# Shorthand commands for Terraform operations
291314.PHONY : tf-init
@@ -303,8 +326,11 @@ tf-destroy: terraform-destroy
303326.PHONY : tf-out
304327tf-out : terraform-output
305328
306- .PHONY : tf-update
307- tf-out : terraform-upgrade
329+ .PHONY : tf-upgrade
330+ tf-upgrade : terraform-upgrade
331+
332+ .PHONY : tf-org-id
333+ tf-org-id : terraform-org-id
308334
309335# Complete Confluent Cloud setup
310336.PHONY : cc-setup
@@ -316,6 +342,8 @@ cc-setup:
316342 fi
317343 @echo " ${BLUE}${INFO} Loading environment variables...${RESET} "
318344 @source .env || true
345+ @echo " ${BLUE}${INFO} Getting Confluent Cloud organization ID...${RESET} "
346+ @$(MAKE ) terraform-org-id
319347 @echo " ${BLUE}${INFO} Initializing Terraform...${RESET} "
320348 @$(MAKE ) terraform-init
321349 @echo " ${BLUE}${INFO} Planning Terraform changes...${RESET} "
0 commit comments