Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 无服务器函数Lambda@Edge在serverless.yml中_Amazon Web Services_Serverless Framework_Serverless - Fatal编程技术网

Amazon web services 无服务器函数Lambda@Edge在serverless.yml中

Amazon web services 无服务器函数Lambda@Edge在serverless.yml中,amazon-web-services,serverless-framework,serverless,Amazon Web Services,Serverless Framework,Serverless,我正在试图弄清楚,是否有可能在同一个文件中使用serverless.yml文件中定义的Lambda函数的ARNLambda@Edge在云面分布上 下面是我的代码,我想在底部指定Lambda函数的ARN,我在同一个无服务器文件中定义了该函数 提前谢谢 functions: myLambdaFunction: handler: handler.myLambdaFunction resources: Resources: WebsiteS3Buck

我正在试图弄清楚,是否有可能在同一个文件中使用serverless.yml文件中定义的Lambda函数的ARNLambda@Edge在云面分布上

下面是我的代码,我想在底部指定Lambda函数的ARN,我在同一个无服务器文件中定义了该函数

提前谢谢

functions:

    myLambdaFunction:
        handler: handler.myLambdaFunction

resources:
    Resources:

        WebsiteS3Bucket:
            Type: AWS::S3::Bucket
            Properties: 
                BucketName: website-bucket
                WebsiteConfiguration:
                    ErrorDocument: index.html
                    IndexDocument: index.html

        WebsiteCloudFrontOriginAccessIdentity:
            Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
            Properties:
                CloudFrontOriginAccessIdentityConfig:
                    Comment: website-bucket-cloudfront-origin-access-identity

        WebsiteS3BucketPolicy:
            Type: AWS::S3::BucketPolicy
            Properties: 
                Bucket: 
                    Ref: WebsiteS3Bucket
                PolicyDocument: 
                    Statement: 
                        - 
                            Action: 
                                - "s3:GetObject"
                                - "s3:ListBucket"
                            Effect: "Allow"
                            Resource: 
                                - Fn::Join: 
                                    - ""
                                    - 
                                        - Fn::GetAtt: [ WebsiteS3Bucket, Arn ]
                                        - "/*"
                                - Fn::Join: 
                                    - ""
                                    - 
                                        - Fn::GetAtt: [ WebsiteS3Bucket, Arn ]
                            Principal:
                                AWS:
                                    Fn::Join:
                                        - ""
                                        -
                                            - "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity "
                                            - Ref: WebsiteCloudFrontOriginAccessIdentity

        WebsiteCloudFront:
            Type: AWS::CloudFront::Distribution
            Properties:
                DistributionConfig: 
                    Enabled: true
                    Origins:
                        -
                            DomainName:
                                Fn::Join:
                                    - ""
                                    -
                                        - Ref: WebsiteS3Bucket
                                        - ".s3.amazonaws.com"
                            Id:
                                Ref: WebsiteS3Bucket
                            S3OriginConfig:
                                OriginAccessIdentity:
                                    Fn::Join:
                                        - ""
                                        -
                                            - "origin-access-identity/cloudfront/"
                                            - Ref: WebsiteCloudFrontOriginAccessIdentity
                    CustomErrorResponses:
                        -
                            ErrorCode: 404
                            ResponseCode: 200
                            ResponsePagePath: /index.html
                    DefaultRootObject: /index.html
                    DefaultCacheBehavior:
                        ForwardedValues:
                            QueryString: true
                        TargetOriginId:
                            Ref: WebsiteS3Bucket
                        ViewerProtocolPolicy: redirect-to-https
                        LambdaFunctionAssociations:
                            -
                                EventType: origin-response
                                LambdaFunctionARN: ## Lambda function ARN here
看起来您已经在模板中引用了Ref。此处引用的内容涉及在Lambda函数上使用Ref时的值:

我通常通过以下方式引用:

!GetAtt [LambdaResourceName, Arn]

嗯,我用输出测试过,但我总是得到未定义的资源。然而,我发现了一个无服务器插件,它似乎正在完成我需要的工作。
!GetAtt [LambdaResourceName, Arn]