Skip to content

Commit df73fd0

Browse files
committed
Adding make commands for confluent cloud environment
1 parent bd6d4ce commit df73fd0

File tree

2 files changed

+69
-4
lines changed

2 files changed

+69
-4
lines changed

Makefile

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ help:
3030
@echo " ${YELLOW}terraform-init${RESET} - Initialize Terraform"
3131
@echo " ${YELLOW}terraform-plan${RESET} - Plan Terraform changes"
3232
@echo " ${YELLOW}terraform-apply${RESET} - Apply Terraform changes"
33+
@echo " ${YELLOW}terraform-destroy${RESET} - Destroy Terraform-managed infrastructure"
34+
@echo " ${YELLOW}terraform-output${RESET} - Generate cloud.properties from Terraform output"
35+
@echo " ${YELLOW}tf-init${RESET} - Shorthand for terraform-init"
36+
@echo " ${YELLOW}tf-plan${RESET} - Shorthand for terraform-plan"
37+
@echo " ${YELLOW}tf-apply${RESET} - Shorthand for terraform-apply"
38+
@echo " ${YELLOW}tf-destroy${RESET} - Shorthand for terraform-destroy"
39+
@echo " ${YELLOW}tf-out${RESET} - Shorthand for terraform-output"
40+
@echo " ${YELLOW}cc-setup${RESET} - Complete Confluent Cloud setup (init, plan, apply, output)"
41+
@echo " ${YELLOW}cc-teardown${RESET} - Teardown Confluent Cloud infrastructure"
3342
@echo " ${YELLOW}clean${RESET} - Clean up temporary files"
3443
@echo " ${YELLOW}check-prereqs${RESET} - Check if all prerequisites are installed"
3544
@echo " ${YELLOW}update-brew-deps${RESET} - Update Homebrew dependencies using Brewfile"
@@ -223,13 +232,67 @@ terraform-apply:
223232
@echo "${BLUE}${ROCKET} Applying Terraform changes...${RESET}"
224233
cd terraform && terraform apply
225234

235+
.PHONY: terraform-destroy
236+
terraform-destroy:
237+
@echo "${BLUE}${WARNING} Destroying Terraform-managed infrastructure...${RESET}"
238+
@echo "${YELLOW}${WARNING} This will destroy all resources created by Terraform!${RESET}"
239+
@read -p "Are you sure you want to continue? (y/N) " confirm; \
240+
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
241+
cd terraform && terraform destroy --auto-approve; \
242+
echo "${GREEN}${CHECK} Infrastructure destroyed!${RESET}"; \
243+
else \
244+
echo "${YELLOW}${INFO} Operation cancelled.${RESET}"; \
245+
fi
246+
226247
# Generate cloud.properties from Terraform output
227-
.PHONY: generate-cloud-properties
228-
generate-cloud-properties:
248+
.PHONY: terraform-output
249+
terraform-output:
229250
@echo "${BLUE}${CLOUD} Generating cloud.properties from Terraform output...${RESET}"
230251
cd terraform && terraform output -json | jq -r 'to_entries | map( {key: .key|tostring|split("_")|join("."), value: .value} ) | map("client.\(.key)=\(.value.value)") | .[]' > ../cloud.properties
231252
@echo "${GREEN}${CHECK} cloud.properties generated!${RESET}"
232253

254+
# Shorthand commands for Terraform operations
255+
.PHONY: tf-init
256+
tf-init: terraform-init
257+
258+
.PHONY: tf-plan
259+
tf-plan: terraform-plan
260+
261+
.PHONY: tf-apply
262+
tf-apply: terraform-apply
263+
264+
.PHONY: tf-destroy
265+
tf-destroy: terraform-destroy
266+
267+
.PHONY: tf-out
268+
tf-out: terraform-output
269+
270+
# Complete Confluent Cloud setup
271+
.PHONY: cc-setup
272+
cc-setup:
273+
@echo "${BLUE}${ROCKET} Setting up Confluent Cloud infrastructure...${RESET}"
274+
@if [ ! -f .env ]; then \
275+
echo "${YELLOW}${WARNING} Environment variables not set. Running setup-terraform first...${RESET}"; \
276+
$(MAKE) setup-terraform; \
277+
fi
278+
@echo "${BLUE}${INFO} Loading environment variables...${RESET}"
279+
@source .env || true
280+
@echo "${BLUE}${INFO} Initializing Terraform...${RESET}"
281+
@$(MAKE) terraform-init
282+
@echo "${BLUE}${INFO} Planning Terraform changes...${RESET}"
283+
@$(MAKE) terraform-plan
284+
@echo "${BLUE}${INFO} Applying Terraform changes...${RESET}"
285+
@$(MAKE) terraform-apply
286+
@echo "${BLUE}${INFO} Generating cloud.properties...${RESET}"
287+
@$(MAKE) terraform-output
288+
@echo "${GREEN}${CHECK} Confluent Cloud setup complete!${RESET}"
289+
290+
# Teardown Confluent Cloud infrastructure
291+
.PHONY: cc-teardown
292+
cc-teardown:
293+
@echo "${BLUE}${WARNING} Tearing down Confluent Cloud infrastructure...${RESET}"
294+
@$(MAKE) terraform-destroy
295+
233296
# Build Gradle project
234297
.PHONY: build
235298
build:

terraform/README.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ Let's assume you have completed the following prereqs:
99
1010
== Shell Setup
1111

12-
Log into Confluent Cloud and find the API Key and API Secret. Use the commands below to set environment variables needed to authenticate to Confluent Cloud:
12+
Log into Confluent Cloud and find the API Key and API Secret.
13+
Use the commands below to set environment variables needed to authenticate to Confluent Cloud:
1314

1415
```shell
1516
export CONFLUENT_CLOUD_API_KEY=<API KEY>
16-
export CONFLUENT_CLOUD_API_SECRET<API SECRET>
17+
export CONFLUENT_CLOUD_API_SECRET=<API SECRET>
1718
```
1819

20+
1921
== Execute Terraform Manifests
2022

2123
The terraform manifests require the Confluent Cloud organization ID in order to provision infrastructure.

0 commit comments

Comments
 (0)