Amazon CloudFront has these 2 features:
For a scenario where:
distMain
with Continous Deployment enabled, staging distribution distStg
, the routing to staging is based on header aws-cf-cd-foo = bar
funcChangeFoo
which will update aws-cf-cd-foo = dood
base on some condition condDood
.distMain
with header aws-cf-cd-foo = bar
but meet condition condDood
My question is, does
funcChangeFoo
run first, change the header aws-cf-cd-foo = dood
and the request continue to distMain
distStg
and the function trigger afterward?Short answer: Continuous Deployment policy is not reevaluated after a viewer or request change. You cannot dynamically route requests from Production
to Staging
distribution with your Lambda@Edge or CloudFront functions. Only built-in features: static headers or weight.
As you said, the Continuous Deployment feature is on top of CloudFront distribution. So its routing policy is executed before reaching the target distribution. Then, the behaviors and its related Lambda@Edge, CloudFront functions are processed.
Continuous Deployment policy is not reevaluated after a viewer or request change. Any manipulations are done within this distribution.
You can consider the Staging
and Production
CloudFront distributions as isolated, without communication or shared configuration.