Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add CloudFront cache invalidation for Static Site services #5035

Merged
merged 9 commits into from
Jul 7, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Resources:
Next: CopyFiles
CopyFiles:
Type: Map
End: true
Next: InvalidateCache
ItemsPath: $.GetMappingFile.files
ItemProcessor:
ProcessorConfig:
Expand Down Expand Up @@ -251,6 +251,18 @@ Resources:
# Required otherwise ContentType won't be applied.
# See https://github.com/aws/aws-sdk-js/issues/1092 for more.
MetadataDirective: 'REPLACE'
InvalidateCache:
Type: Task
End: true
Resource: arn:aws:states:::aws-sdk:cloudfront:createInvalidation
Parameters:
DistributionId: !Ref CloudFrontDistribution
InvalidationBatch:
CallerReference.$: States.UUID()
Paths:
Quantity: 1
Items:
- "/*"

CopyAssetsStateMachineRole:
Metadata:
Expand Down Expand Up @@ -283,6 +295,32 @@ Resources:
Action:
- s3:PutObject
Resource: !Sub arn:aws:s3:::${Bucket}/*
- PolicyName: CacheInvalidation
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- acm:ListCertificates
- cloudfront:GetDistribution
- cloudfront:GetStreamingDistribution
- cloudfront:GetDistributionConfig
- cloudfront:ListDistributions
- cloudfront:ListCloudFrontOriginAccessIdentities
- cloudfront:CreateInvalidation
- cloudfront:GetInvalidation
- cloudfront:ListInvalidations
- elasticloadbalancing:DescribeLoadBalancers
- iam:ListServerCertificates
- sns:ListSubscriptionsByTopic
- sns:ListTopics
- waf:GetWebACL
- waf:ListWebACLs
Resource: "*"
- Effect: Allow
Action:
- s3:ListAllMyBuckets
Resource: arn:aws:s3:::*

EnvManagerS3Access:
Metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Resources:
Next: CopyFiles
CopyFiles:
Type: Map
End: true
Next: InvalidateCache
ItemsPath: $.GetMappingFile.files
ItemProcessor:
ProcessorConfig:
Expand Down Expand Up @@ -283,6 +283,18 @@ Resources:
# Required otherwise ContentType won't be applied.
# See https://github.com/aws/aws-sdk-js/issues/1092 for more.
MetadataDirective: "REPLACE"
InvalidateCache:
Type: Task
End: true
Resource: arn:aws:states:::aws-sdk:cloudfront:createInvalidation
Parameters:
DistributionId: !Ref CloudFrontDistribution
InvalidationBatch:
CallerReference.$: States.UUID()
huanjani marked this conversation as resolved.
Show resolved Hide resolved
Paths:
Quantity: 1
huanjani marked this conversation as resolved.
Show resolved Hide resolved
Items:
- "/*"

CopyAssetsStateMachineRole:
Metadata:
Expand Down Expand Up @@ -318,6 +330,32 @@ Resources:
Action:
- s3:PutObject
Resource: !Sub arn:aws:s3:::${Bucket}/*
- PolicyName: CacheInvalidation
iamhopaul123 marked this conversation as resolved.
Show resolved Hide resolved
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- acm:ListCertificates
- cloudfront:GetDistribution
- cloudfront:GetStreamingDistribution
- cloudfront:GetDistributionConfig
- cloudfront:ListDistributions
- cloudfront:ListCloudFrontOriginAccessIdentities
- cloudfront:CreateInvalidation
- cloudfront:GetInvalidation
- cloudfront:ListInvalidations
- elasticloadbalancing:DescribeLoadBalancers
- iam:ListServerCertificates
- sns:ListSubscriptionsByTopic
- sns:ListTopics
- waf:GetWebACL
- waf:ListWebACLs
Resource: "*"
- Effect: Allow
Action:
- s3:ListAllMyBuckets
Resource: arn:aws:s3:::*

EnvManagerS3Access:
Metadata:
Expand Down