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

Add compute instance template for InSpec #90

Merged
merged 1 commit into from
Jan 28, 2019
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
63 changes: 63 additions & 0 deletions docs/resources/google_compute_instance_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: About the InstanceTemplate resource
platform: gcp
---


## Syntax
A `google_compute_instance_template` is used to test a Google InstanceTemplate resource

## Examples
```
describe google_compute_instance_template(project: 'chef-gcp-inspec', name: 'inspec-gcp-instance-template') do
it { should exist }
its('description') { should eq 'A description of the instance template' }
its('properties.description') { should eq 'A description of the instance itself' }
its('properties.machine_type') { should eq 'n1-standard-1' }
its('properties.tags.items') { should include 'foo' }
its('properties.disks.count') { should eq 1 }
its('properties.disks.first.auto_delete') { should eq 'true' }
its('properties.disks.first.boot') { should eq 'true' }
its('properties.network_interfaces.count') { should eq 1 }
its('properties.service_accounts.count') { should eq 1 }
end

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

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

* `creation_timestamp`: Creation timestamp in RFC3339 text format.

* `description`: An optional description of this resource. Provide this property when you create the resource.

* `id`: The unique identifier for the resource. This identifier is defined by the server.

* `name`: Name of the resource. The name is 1-63 characters long and complies with RFC1035.

* `properties`: The instance properties for this instance template.

* `canIpForward`: Enables instances created based on this template to send packets with source IP addresses other than their own and receive packets with destination IP addresses other than their own. If these instances will be used as an IP gateway or it will be set as the next-hop in a Route resource, specify true. If unsure, leave this set to false.

* `description`: An optional text description for the instances that are created from this instance template.

* `disks`: An array of disks that are associated with the instances that are created from this template.

* `machineType`: The machine type to use in the VM instance template.

* `minCpuPlatform`: Specifies a minimum CPU platform for the VM instance. Applicable values are the friendly names of CPU platforms

* `metadata`: The metadata key/value pairs to assign to instances that are created from this template. These pairs can consist of custom metadata or predefined keys.

* `guestAccelerators`: List of the type and count of accelerator cards attached to the instance

* `networkInterfaces`: An array of configurations for this interface. This specifies how this interface is configured to interact with other network services, such as connecting to the internet. Only one network interface is supported per instance.

* `scheduling`: Sets the scheduling options for this instance.

* `serviceAccounts`: A list of service accounts, with their specified scopes, authorized for this instance. Only one service account per VM instance is supported.

* `tags`: A list of tags to apply to this instance. Tags are used to identify valid sources or targets for network firewalls and are specified by the client during instance creation. The tags can be later modified by the setTags method. Each tag within the list must comply with RFC1035.
29 changes: 29 additions & 0 deletions docs/resources/google_compute_instance_templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: About the InstanceTemplate resource
platform: gcp
---


## Syntax
A `google_compute_instance_templates` is used to test a Google InstanceTemplate resource

## Examples
```
describe google_compute_instance_templates(project: 'chef-gcp-inspec') do
its('names') { should include 'inspec-gcp-instance-template' }
end
```

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

See [google_compute_instance_template.md](google_compute_instance_template.md) for more detailed information
* `creation_timestamps`: an array of `google_compute_instance_template` creation_timestamp
* `descriptions`: an array of `google_compute_instance_template` description
* `ids`: an array of `google_compute_instance_template` id
* `names`: an array of `google_compute_instance_template` name
* `properties`: an array of `google_compute_instance_template` properties

## 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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 Compute
module Property
class InstanceTemplateAccessconfigs
attr_reader :name

attr_reader :nat_ip

attr_reader :type

def initialize(args = nil)
return if args.nil?
@name = args['name']
@nat_ip = args['natIP']
@type = args['type']
end
end

class InstanceTemplateAccessconfigsArray
def self.parse(value)
return if value.nil?
return InstanceTemplateAccessconfigs.new(value) unless value.is_a?(::Array)
value.map { |v| InstanceTemplateAccessconfigs.new(v) }
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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 Compute
module Property
class InstanceTemplateAliasipranges
attr_reader :ip_cidr_range

attr_reader :subnetwork_range_name

def initialize(args = nil)
return if args.nil?
@ip_cidr_range = args['ipCidrRange']
@subnetwork_range_name = args['subnetworkRangeName']
end
end

class InstanceTemplateAliasiprangesArray
def self.parse(value)
return if value.nil?
return InstanceTemplateAliasipranges.new(value) unless value.is_a?(::Array)
value.map { |v| InstanceTemplateAliasipranges.new(v) }
end
end
end
end
end
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.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module Compute
module Property
class InstanceTemplateDiskencryptionkey
attr_reader :raw_key

attr_reader :rsa_encrypted_key

attr_reader :sha256

def initialize(args = nil)
return if args.nil?
@raw_key = args['rawKey']
@rsa_encrypted_key = args['rsaEncryptedKey']
@sha256 = args['sha256']
end
end
end
end
end
67 changes: 67 additions & 0 deletions libraries/google/compute/property/instancetemplate_disks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# 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/compute/property/instancetemplate_disk_encryption_key'
require 'google/compute/property/instancetemplate_initialize_params'
require 'google/compute/property/instancetemplate_source_image_encryption_key'
module GoogleInSpec
module Compute
module Property
class InstanceTemplateDisks
attr_reader :auto_delete

attr_reader :boot

attr_reader :device_name

attr_reader :disk_encryption_key

attr_reader :index

attr_reader :initialize_params

attr_reader :interface

attr_reader :mode

attr_reader :source

attr_reader :type

def initialize(args = nil)
return if args.nil?
@auto_delete = args['autoDelete']
@boot = args['boot']
@device_name = args['deviceName']
@disk_encryption_key = GoogleInSpec::Compute::Property::InstanceTemplateDiskencryptionkey.new(args['diskEncryptionKey'])
@index = args['index']
@initialize_params = GoogleInSpec::Compute::Property::InstanceTemplateInitializeparams.new(args['initializeParams'])
@interface = args['interface']
@mode = args['mode']
@source = args['source']
@type = args['type']
end
end

class InstanceTemplateDisksArray
def self.parse(value)
return if value.nil?
return InstanceTemplateDisks.new(value) unless value.is_a?(::Array)
value.map { |v| InstanceTemplateDisks.new(v) }
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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 Compute
module Property
class InstanceTemplateGuestaccelerators
attr_reader :accelerator_count

attr_reader :accelerator_type

def initialize(args = nil)
return if args.nil?
@accelerator_count = args['acceleratorCount']
@accelerator_type = args['acceleratorType']
end
end

class InstanceTemplateGuestacceleratorsArray
def self.parse(value)
return if value.nil?
return InstanceTemplateGuestaccelerators.new(value) unless value.is_a?(::Array)
value.map { |v| InstanceTemplateGuestaccelerators.new(v) }
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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/compute/property/instancetemplate_source_image_encryption_key'
module GoogleInSpec
module Compute
module Property
class InstanceTemplateInitializeparams
attr_reader :disk_name

attr_reader :disk_size_gb

attr_reader :disk_type

attr_reader :source_image

attr_reader :source_image_encryption_key

def initialize(args = nil)
return if args.nil?
@disk_name = args['diskName']
@disk_size_gb = args['diskSizeGb']
@disk_type = args['diskType']
@source_image = args['sourceImage']
@source_image_encryption_key = GoogleInSpec::Compute::Property::InstanceTemplateSourceimageencryptionkey.new(args['sourceImageEncryptionKey'])
end
end
end
end
end
Loading