Created
July 4, 2018 10:48
-
-
Save bashtoni/995c0683bb18fd19eaefdc296a9401d8 to your computer and use it in GitHub Desktop.
Find ARN for ACM certificate for a given domain name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws acm us-east-1 list-certificates --query CertificateSummaryList[].[CertificateArn,DomainName] \ | |
--output text | grep example.com | cut -f1 |
Thanks for the pure JMESPath verison!
In terms of writing a script I think you almost certainly want to specify the
--region
because this is so important for ACM certificates. For example, all CloudFront certificates must be in us-east-1, meanwhile you might have other resources in other regions.If you omit the
--region
AWS will fallback to default and this could vary between users / AWS environments.
I'd suggest that you use the AWS_REGION
and AWS_PROFILE
variables to handle this - it allows the same script to be used across multiple regions and accounts.
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the gist!
Here's a version with the JMESPath query that adds
--region
and--profile
flags.aws acm list-certificates --query "CertificateSummaryList[?DomainName=='example.com'].CertificateArn" --output text --region us-east-1 --profile default
In terms of writing a script I think you almost certainly want to specify the
--region
because this is so important for ACM certificates. For example, all CloudFront certificates must be in us-east-1, meanwhile you might have other resources in other regions.If you omit the
--region
AWS will fallback to default and this could vary between users / AWS environments.