aws-cloudformation / cfn-lint

CloudFormation Linter
MIT No Attribution
2.4k stars 576 forks source link

v1: E3012 'AWS::NoValue' is not of type 'array' (for conditional array type properties) #3394

Closed cbernander closed 1 week ago

cbernander commented 1 week ago

CloudFormation Lint Version

1.3.4

What operating system are you using?

Ubuntu

Describe the bug

Validation fails when using AWS::NoValue to conditionally set a property that is of Array of X type:

E3012 'AWS::NoValue' is not of type 'array'

Expected behavior

Validation should pass.

Reproduction template

AWSTemplateFormatVersion: 2010-09-09
Parameters:
  UseAliases:
    Default: false
    Type: String
    AllowedValues: [true, false]
Conditions:
  ShouldUseAliases:
    !Equals [true, !Ref UseAliases]
Resources:
  CloudFrontDistribution:
    Type: "AWS::CloudFront::Distribution"
    Properties:
      DistributionConfig:
        Aliases: !If
          - ShouldUseAliases
          -
            - "{{resolve:ssm:/env/fqdns/certifier}}"
          - AWS::NoValue
        DefaultCacheBehavior:
          AllowedMethods:
            - "GET"
            - "HEAD"
          CachedMethods:
            - "GET"
            - "HEAD"
          ForwardedValues:
            QueryString: true
          TargetOriginId: "s3"
          ViewerProtocolPolicy: "https-only"
        Enabled: true
        Origins:
          - Id: "s3"
            DomainName: www.example.com.s3.amazonaws.com"
kddejong commented 1 week ago

Shouldn't that be !Ref AWS::NoValue?

cbernander commented 1 week ago

Yes, of course you are correct - this was an uncaught bug on our side.