mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 07:15:49 +00:00
Added checking previus command state
This commit is contained in:
parent
e10acfa3a5
commit
2032c3a085
1 changed files with 19 additions and 5 deletions
|
@ -6,8 +6,9 @@
|
||||||
# Reqiured: configured AWS CLI
|
# Reqiured: configured AWS CLI
|
||||||
|
|
||||||
read -p "Enter region remove resources from: " REGION
|
read -p "Enter region remove resources from: " REGION
|
||||||
read -p "Enter Project tag key to remove resources from: " TAG_VALUE
|
read -p "Enter tag key to remove resources from: " TAG_KEY
|
||||||
read -p "Enter Project tag value to remove resources from: " TAG_KEY
|
read -p "Enter tag value to remove resources from: " TAG_VALUE
|
||||||
|
read -p "Enter ECR name to remove it from aws: " ECR_NAME
|
||||||
|
|
||||||
|
|
||||||
echo "---------------------------------------"
|
echo "---------------------------------------"
|
||||||
|
@ -16,6 +17,11 @@ echo ""
|
||||||
echo "Deleting EC2 Instances..."
|
echo "Deleting EC2 Instances..."
|
||||||
for instance_id in $(aws ec2 describe-instances --region "$REGION" --query "Reservations[].Instances[?Tags[?Key=='$TAG_KEY'&&Value=='$TAG_VALUE']].InstanceId" --output text); do
|
for instance_id in $(aws ec2 describe-instances --region "$REGION" --query "Reservations[].Instances[?Tags[?Key=='$TAG_KEY'&&Value=='$TAG_VALUE']].InstanceId" --output text); do
|
||||||
aws ec2 terminate-instances --region "$REGION" --instance-ids "$instance_id"
|
aws ec2 terminate-instances --region "$REGION" --instance-ids "$instance_id"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Instance $instance_id terminated successfully."
|
||||||
|
else
|
||||||
|
echo "Error terminating instance $instance_id."
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
echo ""
|
echo ""
|
||||||
echo "---------------------------------------"
|
echo "---------------------------------------"
|
||||||
|
@ -24,9 +30,12 @@ echo ""
|
||||||
|
|
||||||
# Deleting Elastic Container Registry (ECR)
|
# Deleting Elastic Container Registry (ECR)
|
||||||
echo "Deleting Elastic Container Registries (ECR)..."
|
echo "Deleting Elastic Container Registries (ECR)..."
|
||||||
for repo_name in $(aws ecr describe-repositories --region "$REGION" --query "repositories[?Tags[?Key=='$TAG_KEY'&&Value=='$TAG_VALUE']].repositoryName" --output text); do
|
aws ecr delete-repository --region "$REGION" --repository-name "$ECR_NAME" --force
|
||||||
aws ecr delete-repository --region "$REGION" --repository-name "$repo_name" --force
|
if [ $? -eq 0 ]; then
|
||||||
done
|
echo "ECR repository $ECR_NAME deleted successfully."
|
||||||
|
else
|
||||||
|
echo "Error deleting ECR repository $ECR_NAME."
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "---------------------------------------"
|
echo "---------------------------------------"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -36,6 +45,11 @@ echo ""
|
||||||
echo "Deleting VPCs..."
|
echo "Deleting VPCs..."
|
||||||
for vpc_id in $(aws ec2 describe-vpcs --region "$REGION" --query "Vpcs[?Tags[?Key=='$TAG_KEY'&&Value=='$TAG_VALUE']].VpcId" --output text); do
|
for vpc_id in $(aws ec2 describe-vpcs --region "$REGION" --query "Vpcs[?Tags[?Key=='$TAG_KEY'&&Value=='$TAG_VALUE']].VpcId" --output text); do
|
||||||
aws ec2 delete-vpc --region "$REGION" --vpc-id "$vpc_id"
|
aws ec2 delete-vpc --region "$REGION" --vpc-id "$vpc_id"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "VPC $vpc_id deleted successfully."
|
||||||
|
else
|
||||||
|
echo "Error deleting VPC $vpc_id."
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
Loading…
Reference in a new issue