AWS CLI for CloudFront create-invalidation returns old invalidation

I am trying to use AWS CLI to invalidate on CloudFront in my CI service to automatically invalidate files on deployment. However, the CLI returns a success message, but the invalid reference is a month and no new invalid is generated.

I install and enable cloudfront:

pip install awscli
aws configure set preview.cloudfront true
aws configure set preview.create-invalidation true

      

Then I create an invalidation:

aws cloudfront create-invalidation --cli-input-json '{"DistributionId":"ABC123ABC123","InvalidationBatch":{"Paths":{"Quantity":1,"Items":["/index.html"]},"CallerReference":"codeship"}}'

      

Example response when I ran this command at 7/13 at 4:00 pm ET:

{
  "Invalidation": {
    "Status": "Completed",
    "InvalidationBatch": {
      "Paths": {
        "Items": [
          "/index.html"
        ],
        "Quantity": 1
      },
      "CallerReference": "codeship"
    },
    "Id": "1234567890",
    "CreateTime": "2015-06-12T18:39:56.360Z"
  },
  "Location": "https://cloudfront.amazonaws.com/2015-04-17/distribution/ABC123ABC123/invalidation/1234567890"
}

      

When I logged into CloudFront I see one invalid from 6/12, but there was nothing yesterday when I ran this command.

Am I doing something wrong? Does this CLI API keep it working?

+3


source to share


1 answer


It looks like you are passing the same CallerReference for every call to CreateInvalidation? CallerReference uniquely identifies a specific invalidation request, so CloudFront gives you the result of the first invalid use of that CallerReference. From the doc:



The value you provide to uniquely identify the invalidation request. CloudFront uses the value to prevent accidentally resending an identical request. Whenever you create a new invalidation request, you must provide a new value for the CallerReference and change other values ​​in the request, if applicable. One way to ensure that the CallerReference value is unique is to use a timestamp such as 20120301090000.

If you make a second invalidation request with the same value for CallerReference, and if the rest of the request is the same, CloudFront will not create a new invalidation request. Instead, CloudFront returns information about the invalidation request you previously created with the same CallerReference.

If the CallerReference is the value you already submitted in the previous invalidation batch request, but the content of any path is different from the original request, CloudFront returns an InvalidationBatchAlreadyExists error.

+4


source







All Articles