Reputation: 133
I'm kind of stcuk trying to adding a Cloudfront Distribution trigger for a lambda but using cli or sdk. So far from my objective I have added the trigger through console creating a new lambda using the blueprint for "cloudfront-modify-response-header" and it looks like it's working properly but I could not retrieve the information about that trigger using cli I tried:
aws lambda get-policy --function-name myFunctionName --profile xxxx
but I only got a policy with something like:
{
"Policy": {
"Version": "2012-10-17",
"Id": "default",
"Statement": [
{
"Sid": "replicator.lambda.GetFunction",
"Effect": "Allow",
"Principal": {
"Service": "replicator.lambda.amazonaws.com"
},
"Action": "lambda:GetFunction",
"Resource": "arn:aws:lambda:us-east-1: 12345678912:function: myFunctionName: 1"
}
]
},
"RevisionId": "b11abfc7-79a7-489e-9bf7-d501234567899"
}
Where is DistributionID, Event type and other properties that I'm seeing in AWS Console?
Best regards,
Upvotes: 0
Views: 480
Reputation: 238209
The get-distribution API call for cloudfront
has the information about triggers for lambda@edge:
Specifies the event type that triggers a Lambda function invocation. You can specify the following values:
viewer-request : The function executes when CloudFront receives a request from a viewer and before it checks to see whether the requested object is in the edge cache.
origin-request : The function executes only when CloudFront forwards a request to your origin. When the requested object is in the edge cache, the function doesn't execute.
origin-response : The function executes after CloudFront receives a response from the origin and before it caches the object in the response. When the requested object is in the edge cache, the function doesn't execute.
viewer-response : The function executes before CloudFront returns the requested object to the viewer. The function executes regardless of whether the object was already in the edge cache. If the origin returns an HTTP status code other than HTTP 200 (OK), the function doesn't execute.
Upvotes: 1