Skip to content

Instantly share code, notes, and snippets.

@szepeviktor
Created June 22, 2023 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szepeviktor/dea5c6156ebe578a7a6ba677b7ffa9d3 to your computer and use it in GitHub Desktop.
Save szepeviktor/dea5c6156ebe578a7a6ba677b7ffa9d3 to your computer and use it in GitHub Desktop.
Clone AWS Cloudfront distribution
# 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
@ivours
Copy link

ivours commented Jan 17, 2024

Works flawlessly. Thanks for sharing!

@szepeviktor
Copy link
Author

You're welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment