Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
edge-redirector/create-ssl-certificate.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
32 lines (24 sloc)
1.34 KB
This file contains 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
#!/usr/bin/env bash | |
set -eo pipefail | |
DOMAIN_NAME=$1 | |
if [ "$DOMAIN_NAME" = "" ]; then | |
echo "Usage: $0 DOMAIN_NAME" 1>&2 | |
exit 1 | |
fi | |
export AWS_DEFAULT_REGION=us-east-1 | |
SSL_CERTIFICATE_ARN=`aws acm request-certificate --domain-name $DOMAIN_NAME --validation-method DNS | jq --raw-output ".CertificateArn"` | |
echo "Certificate requested for $DOMAIN_NAME." | |
echo "Certificate ARN: $SSL_CERTIFICATE_ARN." | |
CERTIFICATE_STATUS="" | |
until [ "$CERTIFICATE_STATUS" == "PENDING_VALIDATION" ] | |
do | |
CERTIFICATE_STATUS=`aws acm describe-certificate --certificate-arn $SSL_CERTIFICATE_ARN | jq --raw-output ".Certificate.Status"` | |
echo $CERTIFICATE_STATUS | |
sleep 5 | |
done | |
DNS_RECORD_NAME=`aws acm describe-certificate --certificate-arn $SSL_CERTIFICATE_ARN | jq --raw-output ".Certificate.DomainValidationOptions[].ResourceRecord.Name"` | |
DNS_RECORD_TYPE=`aws acm describe-certificate --certificate-arn $SSL_CERTIFICATE_ARN | jq --raw-output ".Certificate.DomainValidationOptions[].ResourceRecord.Type"` | |
DNS_RECORD_VALUE=`aws acm describe-certificate --certificate-arn $SSL_CERTIFICATE_ARN | jq --raw-output ".Certificate.DomainValidationOptions[].ResourceRecord.Value"` | |
echo "Waiting for $DNS_RECORD_TYPE DNS record '$DNS_RECORD_NAME' with value '$DNS_RECORD_VALUE'" | |
aws acm wait certificate-validated --certificate-arn $SSL_CERTIFICATE_ARN | |
echo "SSL certificate issued successfully." |