Home > front end >  Programmatically using the AWS CLI to determine whether an Amazon Redshift cluster is deleted
Programmatically using the AWS CLI to determine whether an Amazon Redshift cluster is deleted

Time:02-18

Pretty much as the title says, would like to find out when a Redshift cluster has been deleted. I'm using this from CI/CD, the prior command is to delete the cluster and I would like to automate more functionality following this check.

Current thinking is to use the describe-cluster endpoint and checking to see whether ClusterNotFound is in the string. Example response from a deleted cluster:

An error occurred (ClusterNotFound) when calling the DescribeClusters operation: Cluster <name> not found.

CodePudding user response:

I would use describe-clusters and check the output to make sure the required cluster is not there.

You can do this with a combination of the AWS CLI and jq:

if [[ $(aws redshift describe-clusters | jq '[.Clusters[].ClusterIdentifier] | any(contains("<name>"))') == "true" ]]; then exit 1; fi
  • Related