Skip to content

Instantly share code, notes, and snippets.

@srkiNZ84
Last active August 4, 2020 08:54
Show Gist options
  • Save srkiNZ84/b4b5fd85dcb2787cd27d0f8d92de4155 to your computer and use it in GitHub Desktop.
Save srkiNZ84/b4b5fd85dcb2787cd27d0f8d92de4155 to your computer and use it in GitHub Desktop.
Bash script to check whether the certificate you've got locally is already in AWS Certificate Manager or not (based on md5sum and tags)
#!/bin/bash
CURRENT_CERT_MD5SUM=af375610c480018271caa1b624c838b3
for acmCertificate in $(aws acm list-certificates | jq -r .CertificateSummaryList[].CertificateArn)
do
echo "Cert ARN is $acmCertificate"
ACM_CERT_MD5SUM=$(aws acm list-tags-for-certificate --certificate-arn $acmCertificate | jq -r '.Tags[] | select(.Key | contains("Md5SumCert")) | .Value')
if [[ "$CURRENT_CERT_MD5SUM" == "$ACM_CERT_MD5SUM" ]]
then
echo "Certificate with ARN $acmCertificate already exists with this certificate data"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment