https://pulumi.com logo
#aws
Title
# aws
p

purple-megabyte-83002

02/11/2022, 6:42 PM
hello how to invalidate Cloudfront distribution cache after updating S3 files ?
l

little-soccer-5693

02/11/2022, 7:04 PM
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

purple-megabyte-83002

02/11/2022, 7:05 PM
im using typescript/javascript
l

little-soccer-5693

02/11/2022, 7:06 PM
check out the dynamic provider link then that's probably a better option for you
p

purple-megabyte-83002

02/11/2022, 7:06 PM
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

little-soccer-5693

02/11/2022, 7:09 PM
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
2 Views