jimmone
jimmone

Reputation: 466

AWS CloudFormation conditions

I have two conditions in my CloudFormation template which are used to choose which resource to deploy based on environment. However when referencing the resource later in the template CloudFormation throws "Unresolved resource dependencies" error. Any idea whats wrong?

Template is shortened for readability. It is working fine without conditions.

Parameters:
  EnvironmentName:
    Type: String

Conditions:
  IsProduction: !Equals [!Ref EnvironmentName, production]
  IsNotProduction: !Not [!Equals [!Ref EnvironmentName, production]]

Resources:
  Lambda:
    Type: AWS::Serverless::Function
    Condition: IsNotProduction

  Lambda:
    Type: AWS::Serverless::Function
    Condition: IsProduction

  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Sub /aws/lambda/${Lambda}

Upvotes: 1

Views: 1092

Answers (1)

Robert Kossendey
Robert Kossendey

Reputation: 6998

So since the template is shortened, it's not that easy to tell what causes this error.

One thing that is problematic though, is that both of your Lambdas are called "Lambda". That won't work, you need to call them differently in your resources section.

Upvotes: 2

Related Questions