简体   繁体   中英

Cannot parse "serverless.yml": bad indentation of a mapping entry

I am including various resources defined in external files and I also have output variables in the resources section.

resources:
  - ${file(resources/api-gateway-errors.yml)}
  - ${file(resources/dynamodb-table.yml)}
  - ${file(resources/cognito-user-pool.yml)}
  - ${file(resources/cognito-identity-pool.yml)}
  Outputs:
    CampaignStateMachine:
      Value: !Ref CreateCampaignStateFunction
    ProspectStateMachine:
      Value: !Ref ProspectCreateStateFunction

With the above code, I get the following error:

 Cannot parse "serverless.yml": bad indentation of a mapping entry in "/Users/user/serverless/outreachful-api/serverless.yml" (101:3)
  
    98 |   - ${file(resources/dynamodb-tab ...
    99 |   - ${file(resources/cognito-user ...
   100 |   - ${file(resources/cognito-iden ...
   101 |   Outputs:
  ---------^
   102 |     CampaignStateMachine:
   103 |       Value: !Ref CreateCampaignS ...

If I remove all the external files and keep only the Outputs as such, there is no error:

resources:
  Outputs:
    CampaignStateMachine:
      Value: !Ref CreateCampaignStateFunction
    ProspectStateMachine:
      Value: !Ref ProspectCreateStateFunction

How should I fix this bad indentation problem while including resources through external files as well as having the Output variables?

Thanks in advance.

Actually, I was looking for the mixed approach of configuring the resources section. I have found the guidelines here under Multiple Configuration Files section.

it's a little bit hard without seeing the example files that you're trying to import, but by just looking at your configuration, it seems like you're mixing array notation and object notation in yaml configuration. I believe the Outputs should also be an item of an array, so something like this:

resources:
  - ${file(resources/api-gateway-errors.yml)}
  - ${file(resources/dynamodb-table.yml)}
  - ${file(resources/cognito-user-pool.yml)}
  - ${file(resources/cognito-identity-pool.yml)}
  - Outputs:
      CampaignStateMachine:
        Value: !Ref CreateCampaignStateFunction
      ProspectStateMachine:
        Value: !Ref ProspectCreateStateFunction

I have a similar issue but I did not face an issue as cited in the examples above.

service: ${file(./envConfig.yml):serviceName}
events:
  - msk:
      arn: ${file(./envConfig.yml):${file(./envConfig.yml):kafkaStage}_kafka_ARN}
      topic: ${file(./envConfig.yml):kafkaStage}.CustomName${file(./envConfig.yml):nameSuffix}

With envConfig.yml containing;

serviceName: ${file(./envConfig.yml):stage}sGenerator${file(./envConfig.yml):nameSuffix}

stage_efsMountARN: arn:aws:elasticfilesystem:xx-abcd-2:0323347012:access-point/fsap-01bgrte4506a947a

prod_efsMountARN: arn:aws:elasticfilesystem:xx-abcd-2:030713434012:access-point/fsap-0cd3rgtdc378013

The value of stage/ prod passed in from another envSuffix.yml

Worked for me.

However my lambda developed in java, uses log4j MDC, and so I wish to pass in environment variable called LOGGIN_PATTERN which as a value of

LOG_PATTERN: '%X{AWSRequestId}', Txn='%X{transaction.id}' %-5p %c{1}:%L - %m%n

and I am getting the mentioned error because of the {AWSRequestId}.

thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM