pulumi / pulumi-aws-static-website

Apache License 2.0
11 stars 5 forks source link

Sync bucket contents via CLI #7

Closed zchase closed 2 years ago

zchase commented 2 years ago

This PR adds two Inputs that allow for you a user to do Atomic Deployments and add Build Identifier to the request headers to help with cache invalidation. Here is an example in YAML:

name: static-website-migration
runtime: yaml
description: A minimal AWS Pulumi YAML program
resources:
  web:
    type: "aws-static-website:index:Website"
    properties:
      sitePath: "../public"
      withCDN: true
      addWebsiteVersionHeader: true
      atomicDeployments: true
outputs:
  websiteURL: ${web.websiteURL}
  bucketName: ${web.bucketName}

There is some fanciness with managing a resource within an apply but we never actually "create" the bucket in the apply. It is used to keep the previous bucket around until the next update just in case a user would need to roll back or do some sort of disaster recovery. Though for that to work the bucketName output on the stack using the component needs to be set. Otherwise, the component will create a new update, update the CDN, and then delete the old bucket.

The build header is attached via a Cloudfront Function so no need to package up a Lambda anymore.