Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How do I describe secondary_ip_ranges of google_compute_subnetwork #311

Open
clintoncwolfe opened this issue Mar 9, 2021 · 1 comment

Comments

@clintoncwolfe
Copy link
Contributor

@sandal-maker commented on Mon Mar 08 2021

This is just question

At the moment, I'm trying to describe secondary_ip_ranges of google_compute_subnetwork Inspec resource.

I have something similar to the following below.

control "my_subnet" do
  impact 1.0
  title "Ensure subnet has the correct properties"
  describe google_compute_subnetwork(project: gcp_project_id, region: region, name: "my-subnet") do
    it { should exist }
    its("purpose") { should cmp "PRIVATE" }
    its("private_ip_google_access") { should be true }
    its("log_config.enable") { should be true }
    its("log_config.flow_sampling") { should cmp "1" }
    its("log_config.aggregation_interval") { should cmp "INTERVAL_15_MIN" }
    its("log_config.metadata") { should include "INCLUDE_ALL_METADATA" }
  end

But I'm not sure how to describe secondary_ip_ranges in my control block.

According to the documentation, its an array.

I've tried iteration as below (and other ways) to no avail.

%w{google_compute_subnetwork(project: gcp_project_id, region: region, name: "my-subnet", beta: true).secondary_ip_ranges}.each do |e|
  describe e do
    its("range_name") { should include "kube-services" }
    # its("e.range_name") { should cmp "kube-services" }
    # it { should include "kube-services" }
    # its("ip_cidr_range") { should eq 443 }
  end
end 

Could somebody explain my mistakes here? I keep getting undefined method 'range_name'

@yurgas
Copy link

yurgas commented Aug 6, 2021

@sandal-maker I had the same question, for me it works this way:

describe google_compute_subnetwork(
    project: gcp_project_id,
    region : region,
    name   : 'my-subnet'
).secondary_ip_ranges[0] do

    its('range_name') { should eq 'pod' }
    its('ip_cidr_range') { should eq '10.20.0.0/16' }
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants