k1LoW / awspec

RSpec tests for your AWS resources.
MIT License
1.17k stars 192 forks source link

Support for using have_record_set for a cname record that point to multiple weighted targets #521

Open danielgpm opened 4 years ago

danielgpm commented 4 years ago

Hi, I have a cname type R53 domain that is pointing to different target domain weighted values (see structure below) How do I test this using the have_record_set function? I'm trying the following:

describe route53_hosted_zone('my_aws_public_zone.'),  do
  it { should exist }
  its(:resource_record_set_count) { should > 2 }
  it { should have_record_set('myapp-domain.com.').type('cname')}
  it { should have_record_set('myapp-domain.com.').cname('myapp-r53-east.com').ttl(300)}
end

but receiving an error:

`block (2 levels) in <top (required)>'

I'm guessing it is because the have_record_set with cname is returning more than 1 target. When I have only 1 target for that cname the above code works.

P.S: Current R53 structure:

myapp-domain.com
 +-- weighted-target-app-east (weight:50)
 |   +-- myapp-r53-east.com
 |       +-- Simple (evaluate_health: True) 
 |           +-- myapp-east.elb.amazonaws.com
 |               +-- IPs
 +-- weighted-target-app-west (weight:50)
 |   +-- myapp-r53-west.com
 |       +-- Simple (evaluate_health: True) 
 |           +-- myapp-west.elb.amazonaws.com
 |               +-- IPs
glasswalk3r commented 3 years ago

@danielgpm , can you please provide the (JSON or even using the SDK client with pry) response for such request based on this resource of yours?

The current available stub (lib/awspec/stub/route53_hosted_zone.rb) includes only this CNAME:

        {
          name: '\052.example.com.',
          type: 'CNAME',
          ttl: 3600,
          resource_records: [
            {
              value: 'example.com'
            }
          ]
        },