-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·34 lines (28 loc) · 904 Bytes
/
run.sh
File metadata and controls
executable file
·34 lines (28 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Ensure the script is run with a project name argument
if [ -z "$1" ]; then
echo "Usage: $0 <project_name>"
exit 1
fi
project_name=$1
# Prompt user for action
echo "Select an action:"
echo "1) Apply (Create Infrastructure)"
echo "2) Destroy (Remove Infrastructure)"
read -p "Enter your choice (1 or 2): " choice
rm .terraform/terraform.tfstate
terraform init -migrate-state \
-backend-config="bucket=platform-devops-new" \
-backend-config="key=terraform/infra/ecs/$project_name/terraform.tfstate" \
-backend-config="region=ap-south-1"
# terraform apply -var="project_names=$project_name"
# terraform destroy
# Execute the chosen action
if [[ "$choice" == "1" ]]; then
terraform apply -auto-approve -var="project_names=$project_name"
elif [[ "$choice" == "2" ]]; then
terraform destroy -var="project_names=$project_name"
else
echo "Invalid choice. Exiting."
exit 1
fi