Skip to content

Instantly share code, notes, and snippets.

@antonioned
Created November 14, 2019 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonioned/268b90d76941f93ad5753875be79d3d2 to your computer and use it in GitHub Desktop.
Save antonioned/268b90d76941f93ad5753875be79d3d2 to your computer and use it in GitHub Desktop.
Python 2.7 Lambda function that does invalidations invoked by S3 bucket changes
from __future__ import print_function
import boto3
import time
def lambda_handler(event, context):
path = ["/*"]
print(path)
client = boto3.client('cloudfront')
invalidation = client.create_invalidation(DistributionId='ID_OF_THE_DISTRIBUTION',
InvalidationBatch={
'Paths': {
'Quantity': 1,
'Items': path
},
'CallerReference': str(time.time())
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment