简体   繁体   中英

AWS CloudFront + API Gateway - detect when deploy finished

I've set up a CloudFront distribution with API Gateway (Edge Optimized) as an origin. From time to time, there is a process that updates the gateway and deploys it through the API (equivalent to the "Deploy API" option on the console).

I'd like to invalidate the cache each time we deploy the gateway, but I couldn't find any information about the deployment process. The only answer I get from the deployment action is the creation time.

The problem is that if I clean the cache right away after the deploy, it won't be enough, and the gateway will give an old response, and CloudFront will cache this.

Does this option exist somewhere? Can I make sure they deploy finished before I clean the cache?

You can use Cloudfront's waiter resource state distributionDeployed .

It's periodically calling the underlying getDistribution() operation every 60 seconds (at most 25 times).

Refer to these references for example: Javascript or Python boto3 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM