Search code examples
amazon-web-servicesamazon-s3amazon-cloudfront

AWS S3 file recently uploaded not updated


I upload a file through AWS Console on S3, and I see there but it's not being updated unless I execute this command on CLI:

 aws cloudfront create-invalidation --distribution-id E1XXXXXXX --paths "/*"

Where E1XXXXXXX is the ID from the CloudFront distribution.

I have a user that will not use the CLI, only has access to Console and only S3, so he just can do 2 things:

  • upload files to some bucket
  • delete files from that bucket

But how can I do in order to get refreshed/updated the file that he is uploading/replacing, without that command on CLI?

Or how can I change the TTL on CloudFront but for an specific Bucket? by default I see a policy with this: enter image description here


Solution

  • Assuming you have a behavior set up that maps your distribution to the S3-origin, you should be able to set your default TTL there. It's the one that will be set for S3-Content.

    enter image description here


    enter image description here


    If that doesn't work, you can attach a Lambda function to the S3 object create event and create an invalidation for changed objects.