philMarius
philMarius

Reputation: 694

Programmatically using the AWS CLI to determine whether an Amazon Redshift cluster is deleted

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.

Upvotes: 0

Views: 741

Answers (1)

gshpychka
gshpychka

Reputation: 11531

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

Upvotes: 2

Related Questions