Serverless v3 Conditions

We were using Serverless Framework Version 2. Now we’re switching it to the version 3. Everything works as is except for the Conditions. They’re just ignored and all the resources are trying to be created on all the environments.

Yaml code sample:

service: service-name
frameworkVersion: '3' # was '2' before

  name: aws
  runtime: provided
  stage: ${opt:stage, 'dev'}
  # some other configs here...

    CreateProdResources: !Equals
      - ${self:provider.stage}
      - prod
      Type: AWS::SQS::Queue
      Condition: CreateProdResources
        # Some SQS properties here

When I switch it over to Serverless v3, my IDE starts complaining on the line: Condition: CreateProdResources, saying “Schema validation: Property ‘Condition’ is not allowed”.

Tried to find anything here: Serverless Framework - Upgrading to v3 - no luck. Google seems also “not aware” of the issue.

Any suggestion please?

I am not sure if this will solve the issue, but a couple of tweaks to clean things up that may, at least, make any issues more apparent:

  1. Having a stage: ${opt:stage, 'dev'} is not necessary. That is already the default action of assigning the stage built into the framework
  2. If you need to access a value for the current stage you can rather use the variable ${sls:stage}. It is way more accurate and may be the cause of your issue. (Serverless Framework Variables)
  3. If you are unsure of how a serverless.yml will look after all variables (such as ${sls:stage} or others) are resolved, you can run the command serverless print with any required region or stage flags added. This will output your serverless.yml with as many variables resolved as possible and can make debugging issues such as this much easier and faster.