我正在使用 cloudformation 来部署我的代码。在我的 yml 文件中,我有这个 DependsOn
属性,我试图为其添加值“AppApiv1Stage”。我尝试了多种方法,每次都会给出不同的错误,不确定我做错了什么。在下面的代码片段中,我首先将其添加在双引号中,如下所示:"AppApiv1Stage"
然后显示错误。我再次尝试使用下面的代码,然后它显示错误“DependsOn 必须是字符串或字符串列表”
Parameters:
ApiStageSecondDeploymentName:
Description: API Stage name to use
Type: String
Default: v1
Resources:
AppAPI:
Type: AWS::Serverless::Api
DependsOn: AuthFunction
Properties:
Name: !Sub ${AWS::StackName}
StageName: !Ref ApiStageSecondDeploymentName
Variables:
LocalTLD: local # Deploys a Dev stage to use for tests and development
MethodSettings:
- LoggingLevel: ERROR
MetricsEnabled: True
DataTraceEnabled: True
HttpMethod: '*'
ResourcePath: '/*'
ThrottlingBurstLimit: !Ref ApiBurstLimit
ThrottlingRateLimit: !Ref ApiRateLimit
ApiMapping:
DependsOn: !Sub AppAPI !Ref ${ApiStageSecondDeploymentName}Stage
Type: AWS::ApiGateway::BasePathMapping
Properties:
BasePath: !Ref ApiStageSecondDeploymentName
DomainName:
Fn::ImportValue: !Sub ${CustomDomainStack}-DNSName
RestApiId: !Ref AppAPI
我也尝试过加入!但再次显示错误。
最佳答案
正如错误所述,not sure what I am doing wrong
DependsOn
必须是字符串,或字符串列表。不是内在函数(Sub、Ref)。
此外,内部函数只能在模板中的少数地方使用,其中没有一个是DependsOn
。来自 docs :
You can use intrinsic functions only in specific parts of a template. Currently, you can use intrinsic functions in resource properties, outputs, metadata attributes, and update policy attributes. You can also use intrinsic functions to conditionally create stack resources.
关于java - 创建变更集时出错 - "DependsOn must be a string or list of strings.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65322944/