cfn-lint icon indicating copy to clipboard operation
cfn-lint copied to clipboard

Template that passes `cfn-lint` fails once deployed to CloudFormation

Open garysassano opened this issue 1 year ago • 3 comments

CloudFormation Lint Version

0.85.2

What operating system are you using?

Ubuntu

Describe the bug

cfn-lint isn't able to validate AWS::CloudFront::Distribution correctly.

I had the following resource passing:

  CloudFrontDistribution:
    Type: AWS::CloudFront::Distribution
    Properties:
      DistributionConfig:
        Enabled: true
        Origins:
          - DomainName: !GetAtt S3Bucket.DomainName
            Id: !Sub "${BucketName}"
            OriginAccessControlId: !Ref CloudFrontOriginAccessControl
            S3OriginConfig: {}
        DefaultCacheBehavior:
          TargetOriginId: !Sub "${BucketName}"
          ViewerProtocolPolicy: "redirect-to-https"

This is not valid though and the deploy would fail:

[ERROR] ResourceType=AWS::CloudFront::Distribution ResourceName=CloudFrontDistribution ResourceStatus=CREATE_FAILED StatusReason="Resource handler returned message: "Invalid request provided: AWS::CloudFront::Distribution: The parameter ForwardedValues is required.

In order for the template to be valid, you either have to provide ForwardedValues (deprecated) or a CachePolicyId.

Expected behavior

cfn-lint warns me that there's a missing required field.

Reproduction template

See above.

garysassano avatar Feb 23 '24 10:02 garysassano

Fixing this in v1 since its an easy fix.

kddejong avatar Feb 26 '24 23:02 kddejong

@kddejong Seems like you already fixed this issue? If not can you please assign this to me?

ArjunMenon-bit avatar Mar 09 '24 06:03 ArjunMenon-bit

I did. This is fixed in the v1 branch. I have left these tickets until v1 is officially released.

kddejong avatar Mar 10 '24 16:03 kddejong