Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CLI delete cloudfront distribution - InvalidIfMatchVersion

I am trying to delete a cloudfront distribution via the AWS CLI. Doing

aws cloudfront delete-distribution --id <DISTRIBUTION-ID>

I am getting the following error:

A client error (InvalidIfMatchVersion) occurred when calling the DeleteDistribution operation: 
The If-Match version is missing or not valid for the resource.

I do not quite understand, what this error means and how to get around it.

From this documentation I assume, that it is necessary to disable the distribution first. But if so - how do I to do this with the CLI?

like image 534
Alexander Presber Avatar asked Oct 01 '14 08:10

Alexander Presber


1 Answers

What is the error that you received? You have not provided an Etag to the CloudFront API when you are modifying your distribution. The possible reason they have this check is that you are not overriding a change that someone else made with your current change.

To get the Etag, run the following command:

$ aws cloudfront get-distribution-config --id E123456

Truncated example output:

{ "ETag": "ETAGEXAMPLE",

$ aws cloudfront delete-distribution --id E123456 --if-match ETAGEXAMPLE

You will ultimately get

"A client error (DistributionNotDisabled) occurred when calling the DeleteDistribution operation: The distribution you are trying to delete has not been disabled.".

You will need to submit an update that disables your distribution and then you will be able to delete it.

like image 180
imperalix Avatar answered Nov 15 '22 05:11

imperalix