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

Feature request: Dns alias sanity check

Open viraptor opened this issue 6 years ago • 4 comments

cfn-lint version: 0.13.1

Description of issue.

I tried to create an elb with a silly error:

 DNSRecord:
   Type: "AWS::Route53::RecordSet"
   Properties:
    AliasTarget:
      DNSName: !GetAtt Elb.DNSName
      HostedZoneId: !Ref HostedZone  <- copy pasta - should be elb's attribute
    HostedZoneId: !Ref HostedZone
    Name: !Ref DomainName
    Type: 'A'

I'm not sure this deserves a rule in cfn-lint, since it's not necessarily an error. But this is a common enough pattern in a recordset:

   AliasTarget:
     DNSName: !GetAtt Elb.DNSName
     HostedZoneId: !GetAtt Elb.CanonicalHostedZoneID

that maybe there should be an info level / clippy style - "It looks like you're trying to create an alias for ELB. Are you sure you didn't mean to use ELB's CanonicalHostedZoneId?"

viraptor avatar Feb 05 '19 03:02 viraptor

Thanks for the feedback. Could be something we could do with a value check here. We're slowly trying to enrich the spec with value data, but we're doing it service by service.

cmmeyer avatar Feb 05 '19 16:02 cmmeyer

I can't image many resources provide back a HostedZoneId valid attribute. Let me see if I can throw together a quick list cause this just becomes a definition in the enriched spec if we can knock out that list.

kddejong avatar Mar 30 '19 12:03 kddejong

Here are the ones I could find. Anyone think of anything else I should look at?

AWS::ElasticLoadBalancing::LoadBalancer.CanonicalHostedZoneNameID AWS::ElasticLoadBalancingV2::LoadBalancer.CanonicalHostedZoneID AWS::ApiGateway::DomainName.DistributionHostedZoneId AWS::ApiGateway::DomainName.RegionalHostedZoneId

kddejong avatar Mar 30 '19 13:03 kddejong

Much easier for us to do this in v1 but a similar exercise to above exists. We need to know what resources provide a hosted zone ID.

It would be similar to our approach here. https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/format_keyword.md

kddejong avatar Jun 19 '24 22:06 kddejong