首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Cloudfront和Lambda@Edge函数的无服务器框架

使用Cloudfront和Lambda@Edge函数的无服务器框架
EN

Stack Overflow用户
提问于 2019-10-10 08:42:27
回答 1查看 375关注 0票数 0

我正在使用下面这个无服务器的yaml,我正在尝试部署一个带有lambda@edge查看器请求和原始请求实验室的cloudfront应用程序。

如果我排除任何cloudfront yaml指令,我可以部署两个lambda。但是当我添加cloudfront指令时,sls deploy会出现以下错误:

代码语言:javascript
复制
Could not find resource with logical name "CloudFrontDistribution"

这是非常通用的,谷歌搜索是有限的。

在生成Cloudfront时,我错过了什么?

这是我的yml,提前谢谢你!

代码语言:javascript
复制
service: ${file(serverless-config/vars-config.yml):service}
custom:
   objectPrefix: '${self:service}-${self:provider.stage}'
   scripts:
     hooks:
       package:initialize: make compile
plugins:
  - '@silvermine/serverless-plugin-cloudfront-lambda-edge'
  - serverless-plugin-scripts
provider:
  name: aws
  runtime: go1.x
  stage: production
  profile: production
  timeout: 300
  region: ${file(serverless-config/vars-config.yml):region}
functions:
   viewerRequestPostGetRewriteHandler:
      name: '${self:custom.objectPrefix}-viewer-request'
      handler: app/functions/ViewerRequestPostGetRewriteHandler.main
      memorySize: 128
      timeout: 1
      events:
      lambdaAtEdge:
        distribution: CloudFrontDistribution
        eventType: viewer-request
   originRequestGetPostRewriteHandler:
      name: '${self:custom.objectPrefix}-viewer-request'
      handler: app/functions/OriginRequestGetPostRewriteHandler.main
      memorySize: 128
      timeout: 1
      events:
      lambdaAtEdge:
        distribution: CloudFrontDistribution
        eventType: origin-request
resources:
  Resources:
    CloudFrontDistribution:
      Type: AWS::CloudFront::Distribution
      Properties:
        DistributionConfig:
          PriceClass: PriceClass_100
EN

回答 1

Stack Overflow用户

发布于 2019-11-28 02:05:16

我使用的设置就像你的一样,它工作得很好。我认为这个错误在某种程度上是正确的。您粘贴的CloudFrontDistribution是不完整的。因此,它没有被创建。错误很难传达给你,因为它看起来像是插件发现了问题,而不是核心应用程序。

为了证明我的理论,继续尝试在不激活插件的情况下启动,您应该会看到与无效的AWS::CloudFront::Distribution资源相关的更好的错误。

要解决此问题,请配置有效的CloudFormation资源。从这里的例子中获得灵感:https://github.com/silvermine/serverless-plugin-cloudfront-lambda-edge#example-cloudfront-static-site-serverless-config

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58313959

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档