Created
November 14, 2019 12:47
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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