hello how to invalidate Cloudfront distribution ca...
# aws
p
hello how to invalidate Cloudfront distribution cache after updating S3 files ?
l
I have this hack after I create a cf distribution because there doesn't appear to be a pulumi primitive for this in the aws provider. golang:
_ = cfDist.ID().ToStringOutput().ApplyT(func(id string) string {
invalidateCfCache(id, resCtx.region)
return fmt.Sprintf("%v", id)
}).(pulumi.StringOutput)
the cleaner way to do this is with a dynamic provider (https://www.pulumi.com/blog/dynamic-providers/) but these are only supported in python/javascript and I'm in golang.
^ invalidateCfCache() above here is just using the aws SDK directly
p
im using typescript/javascript
l
check out the dynamic provider link then that's probably a better option for you
p
okay thank you and where do you find
invalidateCfCache
fn ?
I tried to use
@aws-sdk
in my pulumi script, but this part of the code tries to run during preview.. any doc about how to make it work like a pulumi resource ?
l
oh that's my code. it's just a wrapper around the AWS SDK. here's the js link: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudFront.html#createInvalidation-property
re: make it work like a pulumi resource, yeah that's what the dynamic provider is designed for; see the link above to the pulumi docs
🙏 1