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

feat: Automatically invalidate CDN cache after deployment #2325

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/terraform-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
website-artifacts-path:
type: string
required: true
clear-web-cache:
description: Whether to invalidate the CloudFront distribution cache as a post-deployment step.
type: boolean
default: true
tf-plan-artifacts-key:
type: string
required: true
Expand Down Expand Up @@ -138,3 +142,12 @@ jobs:
AWS_ACCESS_KEY_ID: "${{ steps.decrypt-aws-access-key-id.outputs.out }}"
AWS_SECRET_ACCESS_KEY: "${{ steps.decrypt-aws-secret-access-key.outputs.out }}"
AWS_SESSION_TOKEN: "${{ steps.decrypt-aws-session-token.outputs.out }}"
- name: Invalidate CloudFront distribution cache
if: success() && inputs.clear-web-cache
run:
DISTRIBUTION_ID=$(terraform output -json | jq .website_cloudfront_distribution_id.value)
aws cloudfront create-invalidation --paths '/*' --distribution-id $DISTRIBUTION_ID
env:
AWS_ACCESS_KEY_ID: "${{ steps.decrypt-aws-access-key-id.outputs.out }}"
AWS_SECRET_ACCESS_KEY: "${{ steps.decrypt-aws-secret-access-key.outputs.out }}"
AWS_SESSION_TOKEN: "${{ steps.decrypt-aws-session-token.outputs.out }}"
4 changes: 4 additions & 0 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "website_cloudfront_distribution_id" {
description = "The ID of the CloudFront distribution serving the GOST website."
value = module.website.cloudfront_distribution_id
}
Loading