Does Pūlumi implement a Cloudfront Invalidation? I...
# general
m
Does Pūlumi implement a Cloudfront Invalidation? I can’t find it in the API docs… https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateInvalidation.html
w
There's nothing built in - as this is an imperative action you can take, not a resource you would like to exist. There re many ways to do this though - if you have an S3 bucket for example, you can hook up an event handler on writes to that bucket which sends invalidation requests to cloudfront. Along the lines of https://medium.com/@yagonobre/automatically-invalidate-cloudfront-cache-for-site-hosted-on-s3-3c7818099868, though this would actually be much easier in Pulumi where you can just do
bucket.onObjectCreated(...)
. Alternatively, you could invoke the AWS SDK directly from your Pulumi deployment to force an invalidation. Right now, you would likely do this on every deployment, but we are working on mechanisms to provide more control (like "run this code only when this resource is (re-)created)").
👍 1
m
Thanks @white-balloon-205! I thought that it’s handy that the Pulumi script creates the list of bucket objects that need to be updated, and those are also the objects that would have to be invalidated. I’ll take a look at the links you sent.
a
I don't think the solution suggested will work well. It will create an invalidation request on every new object. It will get worse if you try to invalidate on every update