由于我有一个200资源错误的问题,我找到了一种通过划分为不同的服务来使用交叉堆栈引用的方法。我通过使用跨堆栈引用设法做到了这一点。问题是我不能动态地给出restApiId & restApiRootResourceId。现在,我静态地将ids设置到service-2中。
基本上,service-1看起来像这样,
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-rootResourceIdservice-2看起来像这样
provider:
name: aws
runtime: nodejs8.10
apiGateway-shared:
restApiId:
'Fn::ImportValue': ApiGatewayRestApi-restApiId
restApiRootResourceId:
'Fn::ImportValue': ApiGatewayRestApi-rootResourceId由于上面的service-2配置,我不能引用I。仅供参考:这两个服务位于不同的文件中。那么,这种方法有什么问题呢?
发布于 2019-01-31 20:55:11
Serverless有关于如何访问堆栈输出变量的special syntax:{cf:stackName.outputKey}。请注意,在resources部分中使用Fn::ImportValue是可行的。
https://stackoverflow.com/questions/54454395
复制相似问题