|
30 | 30 | @echo " ${YELLOW}terraform-init${RESET} - Initialize Terraform" |
31 | 31 | @echo " ${YELLOW}terraform-plan${RESET} - Plan Terraform changes" |
32 | 32 | @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" |
33 | 42 | @echo " ${YELLOW}clean${RESET} - Clean up temporary files" |
34 | 43 | @echo " ${YELLOW}check-prereqs${RESET} - Check if all prerequisites are installed" |
35 | 44 | @echo " ${YELLOW}update-brew-deps${RESET} - Update Homebrew dependencies using Brewfile" |
@@ -223,13 +232,67 @@ terraform-apply: |
223 | 232 | @echo "${BLUE}${ROCKET} Applying Terraform changes...${RESET}" |
224 | 233 | cd terraform && terraform apply |
225 | 234 |
|
| 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 | + |
226 | 247 | # Generate cloud.properties from Terraform output |
227 | | -.PHONY: generate-cloud-properties |
228 | | -generate-cloud-properties: |
| 248 | +.PHONY: terraform-output |
| 249 | +terraform-output: |
229 | 250 | @echo "${BLUE}${CLOUD} Generating cloud.properties from Terraform output...${RESET}" |
230 | 251 | cd terraform && terraform output -json | jq -r 'to_entries | map( {key: .key|tostring|split("_")|join("."), value: .value} ) | map("client.\(.key)=\(.value.value)") | .[]' > ../cloud.properties |
231 | 252 | @echo "${GREEN}${CHECK} cloud.properties generated!${RESET}" |
232 | 253 |
|
| 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 | + |
233 | 296 | # Build Gradle project |
234 | 297 | .PHONY: build |
235 | 298 | build: |
|
0 commit comments