Skip to content

Commit

Permalink
Add step to create CDN invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHendrickson committed Dec 8, 2023
1 parent aa7df32 commit 4ab4689
Showing 1 changed file with 13 additions and 0 deletions.
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 }}"

0 comments on commit 4ab4689

Please sign in to comment.