From 4784b71de3432db0ab0b197776a5d77b34dfeb6e Mon Sep 17 00:00:00 2001 From: Chaz Schlarp Date: Sun, 16 Jul 2017 19:21:30 -0700 Subject: [PATCH] Added CloudFront invalidation command --- deploy-template.sh | 3 +++ template.yaml | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/deploy-template.sh b/deploy-template.sh index bee8b4f..4c377f3 100644 --- a/deploy-template.sh +++ b/deploy-template.sh @@ -22,3 +22,6 @@ if [ "$INITIAL_DEPLOY" = "true" ]; then FRONTEND_BUCKET=$(./get-output.sh FrontendBucketName) aws s3 sync ./frontend s3://$FRONTEND_BUCKET/$FRONTEND_PATH fi + +aws configure set preview.cloudfront true +aws cloudfront create-invalidation --distribution-id $(./get-output.sh FrontendDistributionId) --paths '/*' diff --git a/template.yaml b/template.yaml index e9def1c..a6431ca 100644 --- a/template.yaml +++ b/template.yaml @@ -46,7 +46,7 @@ Resources: HttpVersion: http2 Origins: - DomainName: !Select [2, !Split ["/", !GetAtt FrontendS3Bucket.WebsiteURL]] - Id: !Ref FrontendOriginPath + Id: S3Bucket OriginPath: !Join - '' - - / @@ -60,7 +60,7 @@ Resources: MinTTL: 0 DefaultTTL: 2592000 MaxTTL: 2592000 - TargetOriginId: !Ref FrontendOriginPath + TargetOriginId: S3Bucket ViewerProtocolPolicy: redirect-to-https ForwardedValues: QueryString: 'false' @@ -78,6 +78,8 @@ Outputs: - !Ref ServerlessRestApiProdStage FrontendBucketName: Value: !Ref FrontendS3Bucket + FrontendDistributionId: + Value: !Ref FrontendCloudFrontDistribution FrontendUrl: Value: !Join - ''