Created
June 22, 2023 12:36
-
-
Save szepeviktor/dea5c6156ebe578a7a6ba677b7ffa9d3 to your computer and use it in GitHub Desktop.
Clone AWS Cloudfront distribution
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
# Install AWS CLI and jq | |
# Copy existing distribution configuration | |
aws --profile cloudfront cloudfront get-distribution-config --id $DISTRIBUTION_ID --output json \ | |
| jq -r '."DistributionConfig"' >new-distribution.json | |
# Change CallerReference to a new UUID - https://www.uuidgenerator.net/version4 - apt-get install uuid-runtime; uuidgen | |
# Change Aliases.Items[] to new domain name | |
# Search&Replace origin domain name | |
# Change ViewerCertificate.* to new certificate ARN - https://console.aws.amazon.com/acm/home?region=us-east-1#/certificates/request | |
# Create new distribution | |
aws --profile cloudfront cloudfront create-distribution --distribution-config file://new-distribution.json | |
# Add DNS records for CDN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works flawlessly. Thanks for sharing!