jonls / s3-deploy-website

Deploy website to S3/CloudFront from Python
MIT License
29 stars 13 forks source link

How to use in continues integration, and successfully call multiple times #26

Open dkarchmer opened 5 years ago

dkarchmer commented 5 years ago

Sorry, I know this is more of an AWS question, but maybe you have seen this. As I am having trouble figuring it out.

I am basically setting up a continues deployment pipeline, and I am using your tool to deploy to s3/cloudfront. I deployed once successfully but now I am getting this error

botocore.errorfactory.InvalidArgument: An error occurred (InvalidArgument) when calling the CreateInvalidation operation: Your request contains a caller reference that was used for a previous invalidation batch for the same distribution.

My guess is that this is due to

response = cloudfront.create_invalidation(
                DistributionId=dist_id,
                InvalidationBatch=dict(
                    Paths=dict(
                        Quantity=len(paths),
                        Items=paths
                    ),
                    CallerReference='s3-deploy-website'
                )
            )

and the fact that uses the same string as CallerReference.

Should this use instead some string that changes from call to call (maybe adding a datetime.now())?

jonls commented 5 years ago

Thanks, it seems that you are correct. The documentation indicates that this should be a unique string so something like appending the timestamp should work. Would you be able to open a PR?