skip to Main Content

Is it possible to know how cloudformation evaluated a condition?

I have this stack:

Parameters:
  BucketName:
    Default: ''
    Type: String
Conditions:
  CreateBucket: !Not 
    - !Equals 
      - !Ref BucketName
      - 'skip'
Resources:
  Bucket:
    Type: 'AWS::S3::Bucket'
    Condition: CreateBucket

I tried to create an Output:

Outputs:
  CreateBucket:
    Description: "CreateBucket"
    Value: !Ref CreateBucket
    Export:
      Name: "CreateBucket"

But validation fails with:

aws cloudformation validate-template --template-body file://"bucket.yml"

An error occurred (ValidationError) when calling the ValidateTemplate operation: Unresolved resource dependencies [CreateBucket] in the Outputs block of the template

2

Answers


  1. It seems that the inability to output conditions is a specification. Condition is not among the elements that can be included in Output Value.

    Outputs – AWS CloudFormation

    The value of an output can include literals, parameter references, pseudo-parameters, a mapping value, or intrinsic functions.

    Login or Signup to reply.
  2. You can use If function in the output:

    Outputs:
      CreateBucket:
        Description: "CreateBucket"
        Value: !If [CreateBucket, "true", "false"]
        Export:
          Name: "CreateBucket"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search