使用 CLI 或 SDK 将 Cloudfront 触发器添加到 Lambda

Adding Cloudfront trigger to a Lambda using CLI or SDK

我有点想为 lambda 添加 Cloudfront Distribution 触发器,但使用的是 cli 或 sdk。 到目前为止,我的 objective 我已经通过控制台添加了触发器,使用 "cloudfront-modify-response-header" 的蓝图创建了一个新的 lambda,它看起来工作正常,但我无法使用 cli 检索有关该触发器的信息 我试过了:

aws lambda get-policy --function-name myFunctionName --profile xxxx

但我只收到了类似这样的政策:

{
    "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"
}

我在 AWS 控制台中看到的 DistributionID、事件类型和其他属性在哪里?

此致,

get-distribution API 对 cloudfront 的调用包含有关 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.