【问题标题】:Adding Cloudfront trigger to a Lambda using CLI or SDK使用 CLI 或 SDK 将 Cloudfront 触发器添加到 Lambda
【发布时间】:2020-07-27 18:42:06
【问题描述】:

我有点想为 lambda 添加 Cloudfront Distribution 触发器,但使用的是 cli 或 sdk。 到目前为止,我已经通过控制台添加了触发器,使用“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、事件类型和其他属性在哪里?

最好的问候,

【问题讨论】:

    标签: amazon-web-services aws-lambda aws-sdk amazon-cloudfront aws-cli


    【解决方案1】:

    cloudfrontget-distribution API 调用包含有关 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.
    

    【讨论】:

    • 谢谢马尔辛。这很有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-21
    • 2019-01-30
    • 2022-01-06
    • 2020-11-10
    • 1970-01-01
    • 2019-01-02
    相关资源
    最近更新 更多