As far as I have understood, disabling a cloudfront distribution means updating it's status and is necessary to be able to delete it.
Given the very sparse documentation of the AWS CLI, I am looking for a minimal example of how to do that update using just the CLI.
While I can't provide you a minimal example, the following should work. You can obtain jq from your distribution's repository or from http://stedolan.github.io/jq/manual/.
Get the Etag, will need it for step 3:
$ aws cloudfront get-distribution-config --id E123456 | jq '. | .ETag'
Get current config:
$ aws cloudfront get-distribution-config --id E123456 | jq '. | .DistributionConfig' > /tmp/disable-distribution-E123456
Modify /tmp/disable-distribution-E123456, distribution config file to disable.
Relevant section:
Update Distribution:
Oddly enough, the proposed solutions did not work for me. I kept getting
when calling
aws cloudfront delete-distribution
.The issue seems to be that you can't immediately disable the distribution with
aws cloudfront update-distribution
, its status taking a while to be updated (cf. the AWS Console, where the status is shown as 'In Progress').In summary, the following sequence of commands solved my issue:
imperalix's answer works perfect for me! Let me add two more basic commands just incase some new comers (like me) need it: