Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Convert dns managed zone #324

Merged
merged 1 commit into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 63 additions & 29 deletions docs/resources/google_dns_managed_zone.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,90 @@
---
title: About the google_dns_managed_zones Resource
title: About the google_dns_managed_zone resource
platform: gcp
---

# google\_dns\_managed\_zone
## Syntax
A `google_dns_managed_zone` is used to test a Google ManagedZone resource

Use the `google_dns_managed_zones` InSpec audit resource to test properties of a single GCP DNS managed zone.

<br>
## Beta Resource
This resource has beta fields available. To retrieve these fields, include `beta: true` in the constructor for the resource

## Syntax
## Examples
```
describe google_dns_managed_zone(project: 'chef-gcp-inspec', zone: 'example-zone') do
it { should exist }
its('dns_name') { should cmp 'dns-zone-name.com.' }

A `google_dns_managed_zone` resource block declares the tests for a single GCP zone by project and name.
its('description') { should cmp 'example description' }
its('zone_signing_key_algorithm') { should cmp 'rsasha256' }
its('key_signing_key_algorithm') { should cmp 'rsasha512' }
end

describe google_dns_managed_zone(project: 'chef-inspec-gcp', zone: 'zone-name') do
it { should exist }
end
describe google_dns_managed_zone(project: 'chef-gcp-inspec', zone: 'nonexistent') do
it { should_not exist }
end
```

<br>
## Properties
Properties that can be accessed from the `google_dns_managed_zone` resource:

## Examples

The following examples show how to use this InSpec audit resource.
* `description`: A mutable string of at most 1024 characters associated with this resource for the user's convenience. Has no effect on the managed zone's function.

### Test that a GCP compute zone exists
* `dns_name`: The DNS name of this managed zone, for instance "example.com.".

describe google_dns_managed_zone(project: 'chef-inspec-gcp', zone: 'zone-name') do
it { should exist }
end
* `dnssec_config`: DNSSEC configuration

### Test that a GCP DNS managed zone has the expected DNS name
* `kind`: Identifies what kind of resource this is

describe google_dns_managed_zone(project: 'chef-inspec-gcp', zone: 'zone-name') do
its('dns_name') { should match 'mydomain.com' }
end
* `non_existence`: Specifies the mechanism used to provide authenticated denial-of-existence responses.

### Test that a GCP DNS managed zone has expected name server
* `state`: Specifies whether DNSSEC is enabled, and what mode it is in

describe google_dns_managed_zone(project: 'chef-inspec-gcp', zone: 'zone-name') do
its('name_servers') { should include 'ns-cloud-d1.googledomains.com.' }
end
* `default_key_specs`: Specifies parameters that will be used for generating initial DnsKeys for this ManagedZone. If you provide a spec for keySigning or zoneSigning, you must also provide one for the other.

* `algorithm`: String mnemonic specifying the DNSSEC algorithm of this key

<br>
* `key_length`: Length of the keys in bits

## Properties
* `key_type`: Specifies whether this is a key signing key (KSK) or a zone signing key (ZSK). Key signing keys have the Secure Entry Point flag set and, when active, will only be used to sign resource record sets of type DNSKEY. Zone signing keys do not have the Secure Entry Point flag set and will be used to sign all other types of resource record sets.

* `kind`: Identifies what kind of resource this is

* `id`: Unique identifier for the resource; defined by the server.

* `name`: User assigned name for this resource. Must be unique within the project.

* `name_servers`: Delegate your managed_zone to these virtual name servers; defined by the server

* `name_server_set`: Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is a set of DNS name servers that all host the same ManagedZones. Most users will leave this field unset.

* `creation_time`: The time that this resource was created on the server. This is in RFC3339 text format.

* `labels`: A set of key/value label pairs to assign to this ManagedZone.

* `visibility`: The zone's visibility: public zones are exposed to the Internet, while private zones are visible only to Virtual Private Cloud resources. Must be one of: `public`, `private`.

* `private_visibility_config`: For privately visible zones, the set of Virtual Private Cloud resources that the zone is visible from.

* `networks`: The list of VPC networks that can see this zone.

* `network_url`: The fully qualified URL of the VPC network to bind to. This should be formatted like `https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`

* `forwarding_config`: (Beta only) The presence for this field indicates that outbound forwarding is enabled for this zone. The value of this field contains the set of destinations to forward to.

* `target_name_servers`: List of target name servers to forward to. Cloud DNS will select the best available name server if more than one target is given.

* `ipv4_address`: IPv4 address of a target name server.

* `peering_config`: (Beta only) The presence of this field indicates that DNS Peering is enabled for this zone. The value of this field contains the network to peer with.

* `creation_time`, `creation_time_date`, `description`, `dns_name`, `dnssec_config`, `id`, `kind`, `name`, `name_servers`, `key_signing_key_algorithm`, `zone_signing_key_algorithm`
* `target_network`: The network with which to peer.

<br>
* `network_url`: The fully qualified URL of the VPC network to forward queries to. This should be formatted like `https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`


## GCP Permissions

Ensure the [Cloud DNS API](https://console.cloud.google.com/apis/api/dns.googleapis.com/) is enabled for the project.
Ensure the [Google Cloud DNS API](https://console.cloud.google.com/apis/library/dns.googleapis.com/) is enabled for the current project.
88 changes: 31 additions & 57 deletions docs/resources/google_dns_managed_zones.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,46 @@
---
title: About the google_dns_managed_zones Resource
title: About the google_dns_managed_zones resource
platform: gcp
---

# google\_dns\_managed\_zones

Use the `google_dns_managed_zones` InSpec audit resource to test properties of all, or a filtered group of, GCP DNS managed zones for a project.

<br>

## Syntax
A `google_dns_managed_zones` is used to test a Google ManagedZone resource

A `google_dns_managed_zones` resource block collects GCP zones by project then tests that group.

describe google_dns_managed_zones(project: 'chef-inspec-gcp') do
it { should exist }
end

Use this InSpec resource to enumerate IDs then test in-depth using `google_dns_managed_zone`.

google_dns_managed_zones(project: 'chef-inspec-gcp').zone_names.each do |zone_name|
describe google_dns_managed_zone(project: 'chef-inspec-gcp', zone: zone_name) do
it { should exist }
end
end

<br>
## Beta Resource
This resource has beta fields available. To retrieve these fields, include `beta: true` in the constructor for the resource

## Examples

The following examples show how to use this InSpec audit resource.

### Test that there are no more than a specified number of zones available for the project

describe google_dns_managed_zones(project: 'chef-inspec-gcp') do
its('count') { should be <= 100}
end

### Test that an expected, named managed zone is available for the project

describe google_dns_managed_zones(project: 'chef-inspec-gcp') do
its('zone_names') { should include "zone-name" }
end

### Test that a subset of all zones matching "myzone*" exist

google_dns_managed_zones(project: 'chef-inspec-gcp').where(zone_name: /^myzone/).zone_names.each do |zone_name|
describe google_dns_managed_zone(project: 'chef-inspec-gcp', zone: zone_name) do
it { should exist }
end
end

<br>

## Filter Criteria

This resource supports the following filter criteria: `zone_id`; `zone_name`; `zone_dns_name` and `dnssec_enabled`. Any of these may be used with `where`, as a block or as a method.
```
describe google_dns_managed_zones(project: 'chef-gcp-inspec') do
it { should exist }
its('zone_names') { should include 'example-zone' }
its('zone_dns_names') { should include 'dns-zone-name.com.' }
end
```

## Properties
Properties that can be accessed from the `google_dns_managed_zones` resource:

See [google_dns_managed_zone.md](google_dns_managed_zone.md) for more detailed information
* `descriptions`: an array of `google_dns_managed_zone` description
* `zone_dns_names`: an array of `google_dns_managed_zone` dns_name
* `dnssec_configs`: an array of `google_dns_managed_zone` dnssec_config
* `zone_ids`: an array of `google_dns_managed_zone` id
* `zone_names`: an array of `google_dns_managed_zone` name
* `name_servers`: an array of `google_dns_managed_zone` name_servers
* `name_server_sets`: an array of `google_dns_managed_zone` name_server_set
* `creation_times`: an array of `google_dns_managed_zone` creation_time
* `labels`: an array of `google_dns_managed_zone` labels
* `visibilities`: an array of `google_dns_managed_zone` visibility
* `private_visibility_configs`: an array of `google_dns_managed_zone` private_visibility_config
* `forwarding_configs`: (Beta only) an array of `google_dns_managed_zone` forwarding_config
* `peering_configs`: (Beta only) an array of `google_dns_managed_zone` peering_config

* `zone_ids` - an array of google_dns_managed_zone identifier integers
* `zone_names` - an array of google_dns_managed_zone name strings
* `zone_dns_names` - an array of google_dns_managed_zone dns name strings
* `dnssec_config_state`- an array of google_dns_managed_zone dnssec_config boolean values

<br>

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
with `where` as a block or a method.

## GCP Permissions

Ensure the [Cloud DNS API](https://console.cloud.google.com/apis/api/dns.googleapis.com/) is enabled for the project.
Ensure the [Google Cloud DNS API](https://console.cloud.google.com/apis/library/dns.googleapis.com/) is enabled for the current project.
44 changes: 44 additions & 0 deletions libraries/google/dns/property/managedzone_dnssec_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/dns/property/managedzone_dnssec_config_default_key_specs'
module GoogleInSpec
module DNS
module Property
class ManagedZoneDnssecConfig
attr_reader :kind

attr_reader :non_existence

attr_reader :state

attr_reader :default_key_specs

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@kind = args['kind']
@non_existence = args['nonExistence']
@state = args['state']
@default_key_specs = GoogleInSpec::DNS::Property::ManagedZoneDnssecConfigDefaultKeySpecsArray.parse(args['defaultKeySpecs'], to_s)
end

def to_s
"#{@parent_identifier} ManagedZoneDnssecConfig"
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module DNS
module Property
class ManagedZoneDnssecConfigDefaultKeySpecs
attr_reader :algorithm

attr_reader :key_length

attr_reader :key_type

attr_reader :kind

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@algorithm = args['algorithm']
@key_length = args['keyLength']
@key_type = args['keyType']
@kind = args['kind']
end

def to_s
"#{@parent_identifier} ManagedZoneDnssecConfigDefaultKeySpecs"
end
end

class ManagedZoneDnssecConfigDefaultKeySpecsArray
def self.parse(value, parent_identifier)
return if value.nil?
return ManagedZoneDnssecConfigDefaultKeySpecs.new(value, parent_identifier) unless value.is_a?(::Array)
value.map { |v| ManagedZoneDnssecConfigDefaultKeySpecs.new(v, parent_identifier) }
end
end
end
end
end
35 changes: 35 additions & 0 deletions libraries/google/dns/property/managedzone_forwarding_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/dns/property/managedzone_forwarding_config_target_name_servers'
module GoogleInSpec
module DNS
module Property
class ManagedZoneForwardingConfig
attr_reader :target_name_servers

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@target_name_servers = GoogleInSpec::DNS::Property::ManagedZoneForwardingConfigTargetNameServersArray.parse(args['targetNameServers'], to_s)
end

def to_s
"#{@parent_identifier} ManagedZoneForwardingConfig"
end
end
end
end
end
Loading