Error while creating changeset - "DependsOn must be a string or list of strings."

Viewed 1246

I am using cloudformation to deploy my code. In my yml file I ahve this DependsOn attribute for which I am trying to add value as "AppApiv1Stage". I have tried multiple things, everytime it gives different errors not sure what I am doing wrong. In the below code snippet first I added it in double quotes like this:"AppApiv1Stage" then it showed error. Again I tried with below code, then it showed me error as "DependsOn must be a string or list of strings"

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

I also tried with Join! but showing error again.

1 Answers

not sure what I am doing wrong

DependsOn, as the error says, must be a string, or list of strings. Not an intrinsic function (Sub, Ref).

What's more, intrinsic functions can be only used in few places in a template, none of which is DependsOn. From 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.

Related