This repository was archived by the owner on Jan 28, 2025. It is now read-only.
This repository was archived by the owner on Jan 28, 2025. It is now read-only.
How to generate cloudfront Inputs for serverless.yml ? #622
Open
Description
This is a sort of question, not a bug or feature request.
if we want to download current applied CloudFront config command is
cloudfront get-distribution-config --id ############ > current_cloudfront_configuration.json
but this gives JSON as an output, if we want to get apply the output to yml, this is very difficult as we have to map all behaviors, origins, restrictions, etc.
Is there any way we can get or convert currently applied config to the required yml structure?
Because we have lot many configurations in CloudFront, after deployment we use to run a script to overrides the configuration
sleep 30
id="#############"
aws cloudfront get-distribution-config --id "$id" > current_cloudfront_configuration.json --profile prod
lambdaVersion=$( cat current_cloudfront_configuration.json | jq --raw-output '.DistributionConfig.DefaultCacheBehavior.LambdaFunctionAssociations.Items[0].LambdaFunctionARN' | rev | cut -d ":" -f1 | rev )
etag=$( cat current_cloudfront_configuration.json | jq --raw-output '.ETag' )
cp cloudfront.cfg tmp_cloudfront_config.cfg
cloudfrontLambdaARN=$( cat tmp_cloudfront_config.cfg | jq --raw-output '.DefaultCacheBehavior.LambdaFunctionAssociations.Items[].LambdaFunctionARN' )
updatedLambdaARN=$( echo "$cloudfrontLambdaARN" | sed "s/:[^:]*$/:${lambdaVersion}/g" )
sed -i "s/${cloudfrontLambdaARN}/${updatedLambdaARN}/g" tmp_cloudfront_config.cfg
aws cloudfront update-distribution --id "$id" --distribution-config file://tmp_cloudfront_config.cfg --if-match "$etag" --profile prod
rm current_cloudfront_configuration.json
and our serverless.yml
is
myNextApp:
component: "@sls-next/serverless-component@1.17.0-alpha.12"
inputs:
bucketName: my-bucket-name
logLambdaExecutionTimes: true
we want to move all config from JSON to yml.
Thanks in advance.