首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在无服务器yml中访问交叉堆栈引用的restApiId & restApiRootResourceId

无法在无服务器yml中访问交叉堆栈引用的restApiId & restApiRootResourceId
EN

Stack Overflow用户
提问于 2019-01-31 14:12:51
回答 1查看 277关注 0票数 0

由于我有一个200资源错误的问题,我找到了一种通过划分为不同的服务来使用交叉堆栈引用的方法。我通过使用跨堆栈引用设法做到了这一点。问题是我不能动态地给出restApiId & restApiRootResourceId。现在,我静态地将ids设置到service-2中。

基本上,service-1看起来像这样,

代码语言:javascript
复制
provider:
  name: aws
  runtime: nodejs8.10
  apiGateway:
    restApiId: 
      Ref: ApiGatewayRestApi
    restApiResources:
      Fn::GetAtt:
          - ApiGatewayRestApi
          - RootResourceId
custom:
  stage: "${opt:stage, self:provider.stage}"

resources:
  Resources:
    ApiGatewayRestApi:
      Type: AWS::ApiGateway::RestApi
      Properties:
        Name: ${self:service}-${self:custom.stage}-1

  Outputs:
    ApiGatewayRestApiId:
      Value:
        Ref: ApiGatewayRestApi
      Export:
        Name: ApiGatewayRestApi-restApiId

    ApiGatewayRestApiRootResourceId:
      Value:
         Fn::GetAtt:
          - ApiGatewayRestApi
          - RootResourceId 
      Export:
        Name: ApiGatewayRestApi-rootResourceId

service-2看起来像这样

代码语言:javascript
复制
provider:
  name: aws
  runtime: nodejs8.10
  apiGateway-shared:
    restApiId:
      'Fn::ImportValue': ApiGatewayRestApi-restApiId
    restApiRootResourceId:
      'Fn::ImportValue': ApiGatewayRestApi-rootResourceId

由于上面的service-2配置,我不能引用I。仅供参考:这两个服务位于不同的文件中。那么,这种方法有什么问题呢?

EN

回答 1

Stack Overflow用户

发布于 2019-01-31 20:55:11

Serverless有关于如何访问堆栈输出变量的special syntax{cf:stackName.outputKey}。请注意,在resources部分中使用Fn::ImportValue是可行的。

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

https://stackoverflow.com/questions/54454395

复制
相关文章

相似问题

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