java - 创建变更集时出错 - "DependsOn must be a string or list of strings."

标签 java amazon-web-services yaml aws-cloudformation aws-api-gateway

我正在使用 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/

相关文章:

java - 在 Linux 上无需指定数据库名称即可通过 JDBC 连接到 MonetDB

java - 如何使用 Arrays.asList() 对数组执行 List 函数

javascript - 如何将签名的 HTTP 请求从 AWS Lambda 发送到 AppSync GraphQL?

node.js - 在 Elastic Beanstalk 中更新 Nodejs 版本

templates - Github pull request 模板使用 config.yml 检测 YAML front matter 并应用于字段

continuous-integration - Amazon Web Service CodeDeploy appspec.yml 问题

java - JSON 解析器 : IOException: Unable to resolve host "my host address": No address associated with hostname

java - 固定宽度到 GridBagLayout

mysql - aws lambda 函数连接问题 rds 太多

ruby-on-rails - 如何在 Ruby 中的 YAML 文件中包含 YAML 文件