From ce1771b6721d237e97364f794247ca4f6c655e93 Mon Sep 17 00:00:00 2001 From: Samir <85890442+sa-progress@users.noreply.github.com> Date: Thu, 27 Jun 2024 15:57:07 +0530 Subject: [PATCH 1/3] Automatically generated by magic modules for service: bigtableadmin_v2 and resource: Projects__instances__cluster. This commit includes the following changes: - Singular Resource - Plural Resource - Documentation updates - Terraform configuration - Integration tests Signed-off-by: Samir <85890442+sa-progress@users.noreply.github.com> --- ..._bigtableadmin_project_instance_cluster.md | 90 ++++++++++++++++++ ...bigtableadmin_project_instance_clusters.md | 60 ++++++++++++ .../projectinstancecluster_cluster_config.rb | 37 ++++++++ ...uster_config_cluster_autoscaling_config.rb | 39 ++++++++ ...r_autoscaling_config_autoscaling_limits.rb | 37 ++++++++ ..._autoscaling_config_autoscaling_targets.rb | 37 ++++++++ ...rojectinstancecluster_encryption_config.rb | 34 +++++++ ..._bigtableadmin_project_instance_cluster.rb | 72 +++++++++++++++ ...bigtableadmin_project_instance_clusters.rb | 91 +++++++++++++++++++ ..._bigtableadmin_project_instance_cluster.rb | 42 +++++++++ ...bigtableadmin_project_instance_clusters.rb | 33 +++++++ 11 files changed, 572 insertions(+) create mode 100644 docs/resources/google_bigtableadmin_project_instance_cluster.md create mode 100644 docs/resources/google_bigtableadmin_project_instance_clusters.md create mode 100644 libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config.rb create mode 100644 libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config.rb create mode 100644 libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb create mode 100644 libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb create mode 100644 libraries/google/bigtableadmin/property/projectinstancecluster_encryption_config.rb create mode 100644 libraries/google_bigtableadmin_project_instance_cluster.rb create mode 100644 libraries/google_bigtableadmin_project_instance_clusters.rb create mode 100644 test/integration/verify/controls/google_bigtableadmin_project_instance_cluster.rb create mode 100644 test/integration/verify/controls/google_bigtableadmin_project_instance_clusters.rb diff --git a/docs/resources/google_bigtableadmin_project_instance_cluster.md b/docs/resources/google_bigtableadmin_project_instance_cluster.md new file mode 100644 index 00000000..c9e20973 --- /dev/null +++ b/docs/resources/google_bigtableadmin_project_instance_cluster.md @@ -0,0 +1,90 @@ ++++ + +title = "google_bigtableadmin_project_instance_cluster Resource" +platform = "gcp" +draft = false +gh_repo = "inspec-gcp" + + +[menu.inspec] + +title = "google_bigtableadmin_project_instance_cluster" +identifier = "inspec/resources/gcp/google_bigtableadmin_project_instance_cluster Resource" +parent = "inspec/resources/gcp" ++++ + +Use the `google_bigtableadmin_project_instance_cluster` InSpec audit resource to test the properties of a test a Google ProjectInstanceCluster. + +## Installation +{{% inspec_gcp_install %}} + +## Syntax +A `google_bigtableadmin_project_instance_cluster` is used to test a Google ProjectInstanceCluster resource + +## Examples +``` +describe google_bigtableadmin_project_instance_cluster(name: ' value_name') do + it { should exist } + its('name') { should cmp 'value_name' } + its('location') { should cmp 'value_location' } + its('state') { should cmp 'value_state' } + its('default_storage_type') { should cmp 'value_defaultstoragetype' } + +end + +describe google_bigtableadmin_project_instance_cluster(name: "does_not_exit") do + it { should_not exist } +end +``` + +## Parameters +Properties that can be accessed from the `google_bigtableadmin_project_instance_cluster` resource: + +## Properties +Properties that can be accessed from the `google_bigtableadmin_project_instance_cluster` resource: + + + * `name`: The unique name of the cluster. Values are of the form `projects/{project}/instances/{instance}/clusters/a-z*`. + + * `location`: Immutable. The location where this cluster's nodes and storage reside. For best performance, clients should be located as close as possible to this cluster. Currently only zones are supported, so values should be of the form `projects/{project}/locations/{zone}`. + + * `state`: Output only. The current state of the cluster. + Possible values: + * STATE_NOT_KNOWN + * READY + * CREATING + * RESIZING + * DISABLED + + * `serve_nodes`: The number of nodes in the cluster. If no value is set, Cloud Bigtable automatically allocates nodes based on your data footprint and optimized for 50% storage utilization. + + * `cluster_config`: Configuration for a cluster. + + * `cluster_autoscaling_config`: Autoscaling config for a cluster. + + * `autoscaling_limits`: Limits for the number of nodes a Cluster can autoscale up/down to. + + * `min_serve_nodes`: Required. Minimum number of nodes to scale down to. + + * `max_serve_nodes`: Required. Maximum number of nodes to scale up to. + + * `autoscaling_targets`: The Autoscaling targets for a Cluster. These determine the recommended nodes. + + * `cpu_utilization_percent`: The cpu utilization that the Autoscaler should be trying to achieve. This number is on a scale from 0 (no utilization) to 100 (total utilization), and is limited between 10 and 80, otherwise it will return INVALID_ARGUMENT error. + + * `storage_utilization_gib_per_node`: The storage utilization that the Autoscaler should be trying to achieve. This number is limited between 2560 (2.5TiB) and 5120 (5TiB) for a SSD cluster and between 8192 (8TiB) and 16384 (16TiB) for an HDD cluster, otherwise it will return INVALID_ARGUMENT error. If this value is set to 0, it will be treated as if it were set to the default value: 2560 for SSD, 8192 for HDD. + + * `default_storage_type`: Immutable. The type of storage used by this cluster to serve its parent instance's tables, unless explicitly overridden. + Possible values: + * STORAGE_TYPE_UNSPECIFIED + * SSD + * HDD + + * `encryption_config`: Cloud Key Management Service (Cloud KMS) settings for a CMEK-protected cluster. + + * `kms_key_name`: Describes the Cloud KMS encryption key that will be used to protect the destination Bigtable cluster. The requirements for this key are: 1) The Cloud Bigtable service account associated with the project that contains this cluster must be granted the `cloudkms.cryptoKeyEncrypterDecrypter` role on the CMEK key. 2) Only regional keys can be used and the region of the CMEK key must match the region of the cluster. Values are of the form `projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}` + + +## GCP Permissions + +Ensure the [https://bigtableadmin.googleapis.com/](https://console.cloud.google.com/apis/library/bigtableadmin.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_bigtableadmin_project_instance_clusters.md b/docs/resources/google_bigtableadmin_project_instance_clusters.md new file mode 100644 index 00000000..68d8d20f --- /dev/null +++ b/docs/resources/google_bigtableadmin_project_instance_clusters.md @@ -0,0 +1,60 @@ ++++ + +title = "google_bigtableadmin_project_instance_clusters Resource" +platform = "gcp" +draft = false +gh_repo = "inspec-gcp" + + +[menu.inspec] + +title = "google_bigtableadmin_project_instance_clusters" +identifier = "inspec/resources/gcp/google_bigtableadmin_project_instance_clusters Resource" +parent = "inspec/resources/gcp" ++++ + +Use the `google_bigtableadmin_project_instance_clusters` InSpec audit resource to test the properties of a test a Google ProjectInstanceCluster. + +## Installation +{{% inspec_gcp_install %}} + +## Syntax +A `google_bigtableadmin_project_instance_clusters` is used to test a Google ProjectInstanceCluster resource + +## Examples +``` + describe google_bigtableadmin_project_instance_clusters(parent: ' value_parent') do + it { should exist } + end +``` + +## Parameters +Properties that can be accessed from the `google_bigtableadmin_project_instance_clusters` resource: + +See [google_bigtableadmin_project_instance_cluster.md](google_bigtableadmin_project_instance_cluster.md) for more detailed information +* `names`: an array of `google_bigtableadmin_project_instance_cluster` name +* `locations`: an array of `google_bigtableadmin_project_instance_cluster` location +* `states`: an array of `google_bigtableadmin_project_instance_cluster` state +* `serve_nodes`: an array of `google_bigtableadmin_project_instance_cluster` serve_nodes +* `cluster_configs`: an array of `google_bigtableadmin_project_instance_cluster` cluster_config +* `default_storage_types`: an array of `google_bigtableadmin_project_instance_cluster` default_storage_type +* `encryption_configs`: an array of `google_bigtableadmin_project_instance_cluster` encryption_config +## Properties +Properties that can be accessed from the `google_bigtableadmin_project_instance_clusters` resource: + +See [google_bigtableadmin_project_instance_cluster.md](google_bigtableadmin_project_instance_cluster.md) for more detailed information +* `names`: an array of `google_bigtableadmin_project_instance_cluster` name +* `locations`: an array of `google_bigtableadmin_project_instance_cluster` location +* `states`: an array of `google_bigtableadmin_project_instance_cluster` state +* `serve_nodes`: an array of `google_bigtableadmin_project_instance_cluster` serve_nodes +* `cluster_configs`: an array of `google_bigtableadmin_project_instance_cluster` cluster_config +* `default_storage_types`: an array of `google_bigtableadmin_project_instance_cluster` default_storage_type +* `encryption_configs`: an array of `google_bigtableadmin_project_instance_cluster` encryption_config + +## 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 [https://bigtableadmin.googleapis.com/](https://console.cloud.google.com/apis/library/bigtableadmin.googleapis.com/) is enabled for the current project. diff --git a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config.rb b/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config.rb new file mode 100644 index 00000000..a8650ae5 --- /dev/null +++ b/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# 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/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config' +require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits' +require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets' +module GoogleInSpec + module Bigtableadmin + module Property + class ProjectInstanceClusterClusterConfig + attr_reader :cluster_autoscaling_config + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @cluster_autoscaling_config = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterClusterConfigClusterAutoscalingConfig.new(args['clusterAutoscalingConfig'], to_s) + end + + def to_s + "#{@parent_identifier} ProjectInstanceClusterClusterConfig" + end + end + end + end +end diff --git a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config.rb b/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config.rb new file mode 100644 index 00000000..a9c9b147 --- /dev/null +++ b/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# 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/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits' +require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets' +module GoogleInSpec + module Bigtableadmin + module Property + class ProjectInstanceClusterClusterConfigClusterAutoscalingConfig + attr_reader :autoscaling_limits + + attr_reader :autoscaling_targets + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @autoscaling_limits = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingLimits.new(args['autoscalingLimits'], to_s) + @autoscaling_targets = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingTargets.new(args['autoscalingTargets'], to_s) + end + + def to_s + "#{@parent_identifier} ProjectInstanceClusterClusterConfigClusterAutoscalingConfig" + end + end + end + end +end diff --git a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb b/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb new file mode 100644 index 00000000..d52ab19a --- /dev/null +++ b/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# 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 Bigtableadmin + module Property + class ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingLimits + attr_reader :min_serve_nodes + + attr_reader :max_serve_nodes + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @min_serve_nodes = args['minServeNodes'] + @max_serve_nodes = args['maxServeNodes'] + end + + def to_s + "#{@parent_identifier} ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingLimits" + end + end + end + end +end diff --git a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb b/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb new file mode 100644 index 00000000..cc30439b --- /dev/null +++ b/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# 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 Bigtableadmin + module Property + class ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingTargets + attr_reader :cpu_utilization_percent + + attr_reader :storage_utilization_gib_per_node + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @cpu_utilization_percent = args['cpuUtilizationPercent'] + @storage_utilization_gib_per_node = args['storageUtilizationGibPerNode'] + end + + def to_s + "#{@parent_identifier} ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingTargets" + end + end + end + end +end diff --git a/libraries/google/bigtableadmin/property/projectinstancecluster_encryption_config.rb b/libraries/google/bigtableadmin/property/projectinstancecluster_encryption_config.rb new file mode 100644 index 00000000..5e66a1dc --- /dev/null +++ b/libraries/google/bigtableadmin/property/projectinstancecluster_encryption_config.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# 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 Bigtableadmin + module Property + class ProjectInstanceClusterEncryptionConfig + attr_reader :kms_key_name + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @kms_key_name = args['kmsKeyName'] + end + + def to_s + "#{@parent_identifier} ProjectInstanceClusterEncryptionConfig" + end + end + end + end +end diff --git a/libraries/google_bigtableadmin_project_instance_cluster.rb b/libraries/google_bigtableadmin_project_instance_cluster.rb new file mode 100644 index 00000000..796bccc1 --- /dev/null +++ b/libraries/google_bigtableadmin_project_instance_cluster.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# 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 'gcp_backend' +require 'google/bigtableadmin/property/projectinstancecluster_cluster_config' +require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config' +require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits' +require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets' +require 'google/bigtableadmin/property/projectinstancecluster_encryption_config' + +# A provider to manage bigtableadmin resources. +class BigtableadminProjectInstanceCluster < GcpResourceBase + name 'google_bigtableadmin_project_instance_cluster' + desc 'ProjectInstanceCluster' + supports platform: 'gcp' + + attr_reader :params + attr_reader :name + attr_reader :location + attr_reader :state + attr_reader :serve_nodes + attr_reader :cluster_config + attr_reader :default_storage_type + attr_reader :encryption_config + + def initialize(params) + super(params.merge({ use_http_transport: true })) + @params = params + @fetched = @connection.fetch(product_url(params[:beta]), resource_base_url, params, 'Get') + parse unless @fetched.nil? + end + + def parse + @name = @fetched['name'] + @location = @fetched['location'] + @state = @fetched['state'] + @serve_nodes = @fetched['serveNodes'] + @cluster_config = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterClusterConfig.new(@fetched['clusterConfig'], to_s) + @default_storage_type = @fetched['defaultStorageType'] + @encryption_config = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterEncryptionConfig.new(@fetched['encryptionConfig'], to_s) + end + + def exists? + !@fetched.nil? + end + + def to_s + "ProjectInstanceCluster #{@params[:]}" + end + + private + + def product_url(_ = nil) + 'https://bigtableadmin.googleapis.com//v2/' + end + + def resource_base_url + '{{+name}}' + end +end diff --git a/libraries/google_bigtableadmin_project_instance_clusters.rb b/libraries/google_bigtableadmin_project_instance_clusters.rb new file mode 100644 index 00000000..d69765c9 --- /dev/null +++ b/libraries/google_bigtableadmin_project_instance_clusters.rb @@ -0,0 +1,91 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# 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 'gcp_backend' +class BigtableadminProjectInstanceClusters < GcpResourceBase + name 'google_bigtableadmin_project_instance_clusters' + desc 'ProjectInstanceCluster plural resource' + supports platform: 'gcp' + + attr_reader :table + + filter_table_config = FilterTable.create + + filter_table_config.add(:names, field: :name) + filter_table_config.add(:locations, field: :location) + filter_table_config.add(:states, field: :state) + filter_table_config.add(:serve_nodes, field: :serve_nodes) + filter_table_config.add(:cluster_configs, field: :cluster_config) + filter_table_config.add(:default_storage_types, field: :default_storage_type) + filter_table_config.add(:encryption_configs, field: :encryption_config) + + filter_table_config.connect(self, :table) + + def initialize(params = {}) + super(params.merge({ use_http_transport: true })) + @params = params + @table = fetch_wrapped_resource('projectInstanceClusters') + end + + def fetch_wrapped_resource(wrap_path) + # fetch_resource returns an array of responses (to handle pagination) + result = @connection.fetch_all(product_url, resource_base_url, @params, 'Get') + return if result.nil? + + # Conversion of string -> object hash to symbol -> object hash that InSpec needs + converted = [] + result.each do |response| + next if response.nil? || !response.key?(wrap_path) + response[wrap_path].each do |hash| + hash_with_symbols = {} + hash.each_key do |key| + name, value = transform(key, hash) + hash_with_symbols[name] = value + end + converted.push(hash_with_symbols) + end + end + + converted + end + + def transform(key, value) + return transformers[key].call(value) if transformers.key?(key) + + [key.to_sym, value] + end + + def transformers + { + 'name' => ->(obj) { [:name, obj['name']] }, + 'location' => ->(obj) { [:location, obj['location']] }, + 'state' => ->(obj) { [:state, obj['state']] }, + 'serveNodes' => ->(obj) { [:serve_nodes, obj['serveNodes']] }, + 'clusterConfig' => ->(obj) { [:cluster_config, GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterClusterConfig.new(obj['clusterConfig'], to_s)] }, + 'defaultStorageType' => ->(obj) { [:default_storage_type, obj['defaultStorageType']] }, + 'encryptionConfig' => ->(obj) { [:encryption_config, GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterEncryptionConfig.new(obj['encryptionConfig'], to_s)] }, + } + end + + private + + def product_url(_ = nil) + 'https://bigtableadmin.googleapis.com//v2/' + end + + def resource_base_url + '{{+parent}}/clusters' + end +end diff --git a/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster.rb b/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster.rb new file mode 100644 index 00000000..481d5557 --- /dev/null +++ b/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster.rb @@ -0,0 +1,42 @@ +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# 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. +# +# ---------------------------------------------------------------------------- + +title 'Test GCP google_bigtableadmin_project_instance_cluster resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + project_instance_cluster = input('project_instance_cluster', value: { + "name": "value_name", + "parent": "value_parent", + "location": "value_location", + "state": "value_state", + "default_storage_type": "value_defaultstoragetype" +}, description: 'project_instance_cluster description') +control 'google_bigtableadmin_project_instance_cluster-1.0' do + impact 1.0 + title 'google_bigtableadmin_project_instance_cluster resource test' + + describe google_bigtableadmin_project_instance_cluster(name: project_instance_cluster['name']) do + it { should exist } + its('name') { should cmp project_instance_cluster['name'] } + its('location') { should cmp project_instance_cluster['location'] } + its('state') { should cmp project_instance_cluster['state'] } + its('default_storage_type') { should cmp project_instance_cluster['default_storage_type'] } + + end + + describe google_bigtableadmin_project_instance_cluster(name: "does_not_exit") do + it { should_not exist } + end +end diff --git a/test/integration/verify/controls/google_bigtableadmin_project_instance_clusters.rb b/test/integration/verify/controls/google_bigtableadmin_project_instance_clusters.rb new file mode 100644 index 00000000..1a84dcb6 --- /dev/null +++ b/test/integration/verify/controls/google_bigtableadmin_project_instance_clusters.rb @@ -0,0 +1,33 @@ +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# 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. +# +# ---------------------------------------------------------------------------- + +title 'Test GCP google_bigtableadmin_project_instance_clusters resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + project_instance_cluster = input('project_instance_cluster', value: { + "name": "value_name", + "parent": "value_parent", + "location": "value_location", + "state": "value_state", + "default_storage_type": "value_defaultstoragetype" +}, description: 'project_instance_cluster description') +control 'google_bigtableadmin_project_instance_clusters-1.0' do + impact 1.0 + title 'google_bigtableadmin_project_instance_clusters resource test' + + describe google_bigtableadmin_project_instance_clusters(parent: project_instance_cluster['parent']) do + it { should exist } + end +end From 845013819de3f5e999b9e588b23544b80cc1c02c Mon Sep 17 00:00:00 2001 From: balasubramanian-s Date: Mon, 1 Jul 2024 18:34:20 +0530 Subject: [PATCH 2/3] update testcases Signed-off-by: balasubramanian-s --- ...ter.md => google_bigtableadmin_cluster.md} | 19 +++--- .../google_bigtableadmin_clusters.md | 64 +++++++++++++++++++ ...bigtableadmin_project_instance_clusters.md | 60 ----------------- ...er_config.rb => cluster_cluster_config.rb} | 12 ++-- ...ster_config_cluster_autoscaling_config.rb} | 12 ++-- ..._autoscaling_config_autoscaling_limits.rb} | 4 +- ...autoscaling_config_autoscaling_targets.rb} | 4 +- ...config.rb => cluster_encryption_config.rb} | 4 +- ...ter.rb => google_bigtableadmin_cluster.rb} | 22 +++---- ...rs.rb => google_bigtableadmin_clusters.rb} | 12 ++-- .../controls/google_bigtableadmin_cluster.rb | 42 ++++++++++++ .../controls/google_bigtableadmin_clusters.rb | 37 +++++++++++ ..._bigtableadmin_project_instance_cluster.rb | 42 ------------ ...bigtableadmin_project_instance_clusters.rb | 33 ---------- 14 files changed, 187 insertions(+), 180 deletions(-) rename docs/resources/{google_bigtableadmin_project_instance_cluster.md => google_bigtableadmin_cluster.md} (80%) create mode 100644 docs/resources/google_bigtableadmin_clusters.md delete mode 100644 docs/resources/google_bigtableadmin_project_instance_clusters.md rename libraries/google/bigtableadmin/property/{projectinstancecluster_cluster_config.rb => cluster_cluster_config.rb} (62%) rename libraries/google/bigtableadmin/property/{projectinstancecluster_cluster_config_cluster_autoscaling_config.rb => cluster_cluster_config_cluster_autoscaling_config.rb} (62%) rename libraries/google/bigtableadmin/property/{projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb => cluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb} (84%) rename libraries/google/bigtableadmin/property/{projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb => cluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb} (84%) rename libraries/google/bigtableadmin/property/{projectinstancecluster_encryption_config.rb => cluster_encryption_config.rb} (88%) rename libraries/{google_bigtableadmin_project_instance_cluster.rb => google_bigtableadmin_cluster.rb} (65%) rename libraries/{google_bigtableadmin_project_instance_clusters.rb => google_bigtableadmin_clusters.rb} (87%) create mode 100644 test/integration/verify/controls/google_bigtableadmin_cluster.rb create mode 100644 test/integration/verify/controls/google_bigtableadmin_clusters.rb delete mode 100644 test/integration/verify/controls/google_bigtableadmin_project_instance_cluster.rb delete mode 100644 test/integration/verify/controls/google_bigtableadmin_project_instance_clusters.rb diff --git a/docs/resources/google_bigtableadmin_project_instance_cluster.md b/docs/resources/google_bigtableadmin_cluster.md similarity index 80% rename from docs/resources/google_bigtableadmin_project_instance_cluster.md rename to docs/resources/google_bigtableadmin_cluster.md index c9e20973..cd1036d2 100644 --- a/docs/resources/google_bigtableadmin_project_instance_cluster.md +++ b/docs/resources/google_bigtableadmin_cluster.md @@ -1,6 +1,6 @@ +++ -title = "google_bigtableadmin_project_instance_cluster Resource" +title = "google_bigtableadmin_cluster Resource" platform = "gcp" draft = false gh_repo = "inspec-gcp" @@ -8,40 +8,39 @@ gh_repo = "inspec-gcp" [menu.inspec] -title = "google_bigtableadmin_project_instance_cluster" -identifier = "inspec/resources/gcp/google_bigtableadmin_project_instance_cluster Resource" +title = "google_bigtableadmin_cluster" +identifier = "inspec/resources/gcp/google_bigtableadmin_cluster Resource" parent = "inspec/resources/gcp" +++ -Use the `google_bigtableadmin_project_instance_cluster` InSpec audit resource to test the properties of a test a Google ProjectInstanceCluster. +Use the `google_bigtableadmin_cluster` InSpec audit resource to test the properties of a test a Google ProjectInstanceCluster. ## Installation {{% inspec_gcp_install %}} ## Syntax -A `google_bigtableadmin_project_instance_cluster` is used to test a Google ProjectInstanceCluster resource +A `google_bigtableadmin_cluster` is used to test a Google ProjectInstanceCluster resource ## Examples ``` -describe google_bigtableadmin_project_instance_cluster(name: ' value_name') do +describe google_bigtableadmin_cluster(name: 'value_name') do it { should exist } its('name') { should cmp 'value_name' } its('location') { should cmp 'value_location' } its('state') { should cmp 'value_state' } its('default_storage_type') { should cmp 'value_defaultstoragetype' } - end -describe google_bigtableadmin_project_instance_cluster(name: "does_not_exit") do +describe google_bigtableadmin_cluster(name: "does_not_exit") do it { should_not exist } end ``` ## Parameters -Properties that can be accessed from the `google_bigtableadmin_project_instance_cluster` resource: +Properties that can be accessed from the `google_bigtableadmin_cluster` resource: ## Properties -Properties that can be accessed from the `google_bigtableadmin_project_instance_cluster` resource: +Properties that can be accessed from the `google_bigtableadmin_cluster` resource: * `name`: The unique name of the cluster. Values are of the form `projects/{project}/instances/{instance}/clusters/a-z*`. diff --git a/docs/resources/google_bigtableadmin_clusters.md b/docs/resources/google_bigtableadmin_clusters.md new file mode 100644 index 00000000..d16a1839 --- /dev/null +++ b/docs/resources/google_bigtableadmin_clusters.md @@ -0,0 +1,64 @@ ++++ + +title = "google_bigtableadmin_clusters Resource" +platform = "gcp" +draft = false +gh_repo = "inspec-gcp" + + +[menu.inspec] + +title = "google_bigtableadmin_clusters" +identifier = "inspec/resources/gcp/google_bigtableadmin_clusters Resource" +parent = "inspec/resources/gcp" ++++ + +Use the `google_bigtableadmin_clusters` InSpec audit resource to test the properties of a test a Google ProjectInstanceCluster. + +## Installation +{{% inspec_gcp_install %}} + +## Syntax +A `google_bigtableadmin_clusters` is used to test a Google ProjectInstanceCluster resource + +## Examples +``` + describe google_bigtableadmin_clusters(parent: ' value_parent') do + it { should exist } + its('names') { should include 'value_name' } + its('locations') { should include 'value_location' } + its('states') { should include 'value_state' } + its('default_storage_types') { should include 'value_defaultstoragetype' } + end +``` + +## Parameters +Properties that can be accessed from the `google_bigtableadmin_clusters` resource: + +See [google_bigtableadmin_cluster.md](google_bigtableadmin_cluster.md) for more detailed information +* `names`: an array of `google_bigtableadmin_cluster` name +* `locations`: an array of `google_bigtableadmin_cluster` location +* `states`: an array of `google_bigtableadmin_cluster` state +* `serve_nodes`: an array of `google_bigtableadmin_cluster` serve_nodes +* `cluster_configs`: an array of `google_bigtableadmin_cluster` cluster_config +* `default_storage_types`: an array of `google_bigtableadmin_cluster` default_storage_type +* `encryption_configs`: an array of `google_bigtableadmin_cluster` encryption_config +## Properties +Properties that can be accessed from the `google_bigtableadmin_clusters` resource: + +See [google_bigtableadmin_cluster.md](google_bigtableadmin_cluster.md) for more detailed information +* `names`: an array of `google_bigtableadmin_cluster` name +* `locations`: an array of `google_bigtableadmin_cluster` location +* `states`: an array of `google_bigtableadmin_cluster` state +* `serve_nodes`: an array of `google_bigtableadmin_cluster` serve_nodes +* `cluster_configs`: an array of `google_bigtableadmin_cluster` cluster_config +* `default_storage_types`: an array of `google_bigtableadmin_cluster` default_storage_type +* `encryption_configs`: an array of `google_bigtableadmin_cluster` encryption_config + +## 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 [https://bigtableadmin.googleapis.com/](https://console.cloud.google.com/apis/library/bigtableadmin.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_bigtableadmin_project_instance_clusters.md b/docs/resources/google_bigtableadmin_project_instance_clusters.md deleted file mode 100644 index 68d8d20f..00000000 --- a/docs/resources/google_bigtableadmin_project_instance_clusters.md +++ /dev/null @@ -1,60 +0,0 @@ -+++ - -title = "google_bigtableadmin_project_instance_clusters Resource" -platform = "gcp" -draft = false -gh_repo = "inspec-gcp" - - -[menu.inspec] - -title = "google_bigtableadmin_project_instance_clusters" -identifier = "inspec/resources/gcp/google_bigtableadmin_project_instance_clusters Resource" -parent = "inspec/resources/gcp" -+++ - -Use the `google_bigtableadmin_project_instance_clusters` InSpec audit resource to test the properties of a test a Google ProjectInstanceCluster. - -## Installation -{{% inspec_gcp_install %}} - -## Syntax -A `google_bigtableadmin_project_instance_clusters` is used to test a Google ProjectInstanceCluster resource - -## Examples -``` - describe google_bigtableadmin_project_instance_clusters(parent: ' value_parent') do - it { should exist } - end -``` - -## Parameters -Properties that can be accessed from the `google_bigtableadmin_project_instance_clusters` resource: - -See [google_bigtableadmin_project_instance_cluster.md](google_bigtableadmin_project_instance_cluster.md) for more detailed information -* `names`: an array of `google_bigtableadmin_project_instance_cluster` name -* `locations`: an array of `google_bigtableadmin_project_instance_cluster` location -* `states`: an array of `google_bigtableadmin_project_instance_cluster` state -* `serve_nodes`: an array of `google_bigtableadmin_project_instance_cluster` serve_nodes -* `cluster_configs`: an array of `google_bigtableadmin_project_instance_cluster` cluster_config -* `default_storage_types`: an array of `google_bigtableadmin_project_instance_cluster` default_storage_type -* `encryption_configs`: an array of `google_bigtableadmin_project_instance_cluster` encryption_config -## Properties -Properties that can be accessed from the `google_bigtableadmin_project_instance_clusters` resource: - -See [google_bigtableadmin_project_instance_cluster.md](google_bigtableadmin_project_instance_cluster.md) for more detailed information -* `names`: an array of `google_bigtableadmin_project_instance_cluster` name -* `locations`: an array of `google_bigtableadmin_project_instance_cluster` location -* `states`: an array of `google_bigtableadmin_project_instance_cluster` state -* `serve_nodes`: an array of `google_bigtableadmin_project_instance_cluster` serve_nodes -* `cluster_configs`: an array of `google_bigtableadmin_project_instance_cluster` cluster_config -* `default_storage_types`: an array of `google_bigtableadmin_project_instance_cluster` default_storage_type -* `encryption_configs`: an array of `google_bigtableadmin_project_instance_cluster` encryption_config - -## 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 [https://bigtableadmin.googleapis.com/](https://console.cloud.google.com/apis/library/bigtableadmin.googleapis.com/) is enabled for the current project. diff --git a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config.rb b/libraries/google/bigtableadmin/property/cluster_cluster_config.rb similarity index 62% rename from libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config.rb rename to libraries/google/bigtableadmin/property/cluster_cluster_config.rb index a8650ae5..86ea87a4 100644 --- a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config.rb +++ b/libraries/google/bigtableadmin/property/cluster_cluster_config.rb @@ -13,23 +13,23 @@ # CONTRIBUTING.md located at the root of this package. # # ---------------------------------------------------------------------------- -require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config' -require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits' -require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets' +require 'google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config' +require 'google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_limits' +require 'google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_targets' module GoogleInSpec module Bigtableadmin module Property - class ProjectInstanceClusterClusterConfig + class ClusterClusterConfig attr_reader :cluster_autoscaling_config def initialize(args = nil, parent_identifier = nil) return if args.nil? @parent_identifier = parent_identifier - @cluster_autoscaling_config = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterClusterConfigClusterAutoscalingConfig.new(args['clusterAutoscalingConfig'], to_s) + @cluster_autoscaling_config = GoogleInSpec::Bigtableadmin::Property::ClusterClusterConfigClusterAutoscalingConfig.new(args['clusterAutoscalingConfig'], to_s) end def to_s - "#{@parent_identifier} ProjectInstanceClusterClusterConfig" + "#{@parent_identifier} ClusterClusterConfig" end end end diff --git a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config.rb b/libraries/google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config.rb similarity index 62% rename from libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config.rb rename to libraries/google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config.rb index a9c9b147..228cd84b 100644 --- a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config.rb +++ b/libraries/google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config.rb @@ -13,12 +13,12 @@ # CONTRIBUTING.md located at the root of this package. # # ---------------------------------------------------------------------------- -require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits' -require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets' +require 'google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_limits' +require 'google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_targets' module GoogleInSpec module Bigtableadmin module Property - class ProjectInstanceClusterClusterConfigClusterAutoscalingConfig + class ClusterClusterConfigClusterAutoscalingConfig attr_reader :autoscaling_limits attr_reader :autoscaling_targets @@ -26,12 +26,12 @@ class ProjectInstanceClusterClusterConfigClusterAutoscalingConfig def initialize(args = nil, parent_identifier = nil) return if args.nil? @parent_identifier = parent_identifier - @autoscaling_limits = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingLimits.new(args['autoscalingLimits'], to_s) - @autoscaling_targets = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingTargets.new(args['autoscalingTargets'], to_s) + @autoscaling_limits = GoogleInSpec::Bigtableadmin::Property::ClusterClusterConfigClusterAutoscalingConfigAutoscalingLimits.new(args['autoscalingLimits'], to_s) + @autoscaling_targets = GoogleInSpec::Bigtableadmin::Property::ClusterClusterConfigClusterAutoscalingConfigAutoscalingTargets.new(args['autoscalingTargets'], to_s) end def to_s - "#{@parent_identifier} ProjectInstanceClusterClusterConfigClusterAutoscalingConfig" + "#{@parent_identifier} ClusterClusterConfigClusterAutoscalingConfig" end end end diff --git a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb b/libraries/google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb similarity index 84% rename from libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb rename to libraries/google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb index d52ab19a..08b51d50 100644 --- a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb +++ b/libraries/google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_limits.rb @@ -16,7 +16,7 @@ module GoogleInSpec module Bigtableadmin module Property - class ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingLimits + class ClusterClusterConfigClusterAutoscalingConfigAutoscalingLimits attr_reader :min_serve_nodes attr_reader :max_serve_nodes @@ -29,7 +29,7 @@ def initialize(args = nil, parent_identifier = nil) end def to_s - "#{@parent_identifier} ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingLimits" + "#{@parent_identifier} ClusterClusterConfigClusterAutoscalingConfigAutoscalingLimits" end end end diff --git a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb b/libraries/google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb similarity index 84% rename from libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb rename to libraries/google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb index cc30439b..0a6bf130 100644 --- a/libraries/google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb +++ b/libraries/google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_targets.rb @@ -16,7 +16,7 @@ module GoogleInSpec module Bigtableadmin module Property - class ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingTargets + class ClusterClusterConfigClusterAutoscalingConfigAutoscalingTargets attr_reader :cpu_utilization_percent attr_reader :storage_utilization_gib_per_node @@ -29,7 +29,7 @@ def initialize(args = nil, parent_identifier = nil) end def to_s - "#{@parent_identifier} ProjectInstanceClusterClusterConfigClusterAutoscalingConfigAutoscalingTargets" + "#{@parent_identifier} ClusterClusterConfigClusterAutoscalingConfigAutoscalingTargets" end end end diff --git a/libraries/google/bigtableadmin/property/projectinstancecluster_encryption_config.rb b/libraries/google/bigtableadmin/property/cluster_encryption_config.rb similarity index 88% rename from libraries/google/bigtableadmin/property/projectinstancecluster_encryption_config.rb rename to libraries/google/bigtableadmin/property/cluster_encryption_config.rb index 5e66a1dc..20e7aca9 100644 --- a/libraries/google/bigtableadmin/property/projectinstancecluster_encryption_config.rb +++ b/libraries/google/bigtableadmin/property/cluster_encryption_config.rb @@ -16,7 +16,7 @@ module GoogleInSpec module Bigtableadmin module Property - class ProjectInstanceClusterEncryptionConfig + class ClusterEncryptionConfig attr_reader :kms_key_name def initialize(args = nil, parent_identifier = nil) @@ -26,7 +26,7 @@ def initialize(args = nil, parent_identifier = nil) end def to_s - "#{@parent_identifier} ProjectInstanceClusterEncryptionConfig" + "#{@parent_identifier} ClusterEncryptionConfig" end end end diff --git a/libraries/google_bigtableadmin_project_instance_cluster.rb b/libraries/google_bigtableadmin_cluster.rb similarity index 65% rename from libraries/google_bigtableadmin_project_instance_cluster.rb rename to libraries/google_bigtableadmin_cluster.rb index 796bccc1..68022d79 100644 --- a/libraries/google_bigtableadmin_project_instance_cluster.rb +++ b/libraries/google_bigtableadmin_cluster.rb @@ -14,15 +14,15 @@ # # ---------------------------------------------------------------------------- require 'gcp_backend' -require 'google/bigtableadmin/property/projectinstancecluster_cluster_config' -require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config' -require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_limits' -require 'google/bigtableadmin/property/projectinstancecluster_cluster_config_cluster_autoscaling_config_autoscaling_targets' -require 'google/bigtableadmin/property/projectinstancecluster_encryption_config' +require 'google/bigtableadmin/property/cluster_cluster_config' +require 'google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config' +require 'google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_limits' +require 'google/bigtableadmin/property/cluster_cluster_config_cluster_autoscaling_config_autoscaling_targets' +require 'google/bigtableadmin/property/cluster_encryption_config' # A provider to manage bigtableadmin resources. class BigtableadminProjectInstanceCluster < GcpResourceBase - name 'google_bigtableadmin_project_instance_cluster' + name 'google_bigtableadmin_cluster' desc 'ProjectInstanceCluster' supports platform: 'gcp' @@ -47,9 +47,9 @@ def parse @location = @fetched['location'] @state = @fetched['state'] @serve_nodes = @fetched['serveNodes'] - @cluster_config = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterClusterConfig.new(@fetched['clusterConfig'], to_s) + @cluster_config = GoogleInSpec::Bigtableadmin::Property::ClusterClusterConfig.new(@fetched['clusterConfig'], to_s) @default_storage_type = @fetched['defaultStorageType'] - @encryption_config = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterEncryptionConfig.new(@fetched['encryptionConfig'], to_s) + @encryption_config = GoogleInSpec::Bigtableadmin::Property::ClusterEncryptionConfig.new(@fetched['encryptionConfig'], to_s) end def exists? @@ -57,16 +57,16 @@ def exists? end def to_s - "ProjectInstanceCluster #{@params[:]}" + "ProjectInstanceCluster #{@params[:name]}" end private def product_url(_ = nil) - 'https://bigtableadmin.googleapis.com//v2/' + 'https://bigtableadmin.googleapis.com/v2/' end def resource_base_url - '{{+name}}' + '{{name}}' end end diff --git a/libraries/google_bigtableadmin_project_instance_clusters.rb b/libraries/google_bigtableadmin_clusters.rb similarity index 87% rename from libraries/google_bigtableadmin_project_instance_clusters.rb rename to libraries/google_bigtableadmin_clusters.rb index d69765c9..ed8adeec 100644 --- a/libraries/google_bigtableadmin_project_instance_clusters.rb +++ b/libraries/google_bigtableadmin_clusters.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' class BigtableadminProjectInstanceClusters < GcpResourceBase - name 'google_bigtableadmin_project_instance_clusters' + name 'google_bigtableadmin_clusters' desc 'ProjectInstanceCluster plural resource' supports platform: 'gcp' @@ -36,7 +36,7 @@ class BigtableadminProjectInstanceClusters < GcpResourceBase def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params - @table = fetch_wrapped_resource('projectInstanceClusters') + @table = fetch_wrapped_resource('clusters') end def fetch_wrapped_resource(wrap_path) @@ -73,19 +73,19 @@ def transformers 'location' => ->(obj) { [:location, obj['location']] }, 'state' => ->(obj) { [:state, obj['state']] }, 'serveNodes' => ->(obj) { [:serve_nodes, obj['serveNodes']] }, - 'clusterConfig' => ->(obj) { [:cluster_config, GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterClusterConfig.new(obj['clusterConfig'], to_s)] }, + 'clusterConfig' => ->(obj) { [:cluster_config, GoogleInSpec::Bigtableadmin::Property::ClusterClusterConfig.new(obj['clusterConfig'], to_s)] }, 'defaultStorageType' => ->(obj) { [:default_storage_type, obj['defaultStorageType']] }, - 'encryptionConfig' => ->(obj) { [:encryption_config, GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterEncryptionConfig.new(obj['encryptionConfig'], to_s)] }, + 'encryptionConfig' => ->(obj) { [:encryption_config, GoogleInSpec::Bigtableadmin::Property::ClusterEncryptionConfig.new(obj['encryptionConfig'], to_s)] }, } end private def product_url(_ = nil) - 'https://bigtableadmin.googleapis.com//v2/' + 'https://bigtableadmin.googleapis.com/v2/' end def resource_base_url - '{{+parent}}/clusters' + '{{parent}}/clusters' end end diff --git a/test/integration/verify/controls/google_bigtableadmin_cluster.rb b/test/integration/verify/controls/google_bigtableadmin_cluster.rb new file mode 100644 index 00000000..9f9b8771 --- /dev/null +++ b/test/integration/verify/controls/google_bigtableadmin_cluster.rb @@ -0,0 +1,42 @@ +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# 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. +# +# ---------------------------------------------------------------------------- + +title 'Test GCP google_bigtableadmin_cluster resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + cluster = input('cluster', value: { + "name": "projects/ppradhan/instances/inspec-test/clusters/inspec-test-c1", + "parent": "projects/ppradhan/instances/inspec-test", + "location": "projects/ppradhan/locations/us-central1-f", + "state": "READY", + "default_storage_type": "SSD" +}, description: 'cluster description') +control 'google_bigtableadmin_cluster-1.0' do + impact 1.0 + title 'google_bigtableadmin_cluster resource test' + + describe google_bigtableadmin_cluster(name: cluster['name']) do + it { should exist } + its('name') { should cmp cluster['name'] } + its('location') { should cmp cluster['location'] } + its('state') { should cmp cluster['state'] } + its('default_storage_type') { should cmp cluster['default_storage_type'] } + + end + + describe google_bigtableadmin_cluster(name: "does_not_exit") do + it { should_not exist } + end +end diff --git a/test/integration/verify/controls/google_bigtableadmin_clusters.rb b/test/integration/verify/controls/google_bigtableadmin_clusters.rb new file mode 100644 index 00000000..fa5199ee --- /dev/null +++ b/test/integration/verify/controls/google_bigtableadmin_clusters.rb @@ -0,0 +1,37 @@ +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# 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. +# +# ---------------------------------------------------------------------------- + +title 'Test GCP google_bigtableadmin_clusters resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + cluster = input('cluster', value: { + "name": "projects/ppradhan/instances/inspec-test/clusters/inspec-test-c1", + "parent": "projects/ppradhan/instances/inspec-test", + "location": "projects/ppradhan/locations/us-central1-f", + "state": "READY", + "default_storage_type": "SSD" +}, description: 'cluster description') +control 'google_bigtableadmin_clusters-1.0' do + impact 1.0 + title 'google_bigtableadmin_clusters resource test' + + describe google_bigtableadmin_clusters(parent: cluster['parent']) do + it { should exist } + its('names') { should include cluster['name'] } + its('locations') { should include cluster['location'] } + its('states') { should include cluster['state'] } + its('default_storage_types') { should include cluster['default_storage_type'] } + end +end diff --git a/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster.rb b/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster.rb deleted file mode 100644 index 481d5557..00000000 --- a/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster.rb +++ /dev/null @@ -1,42 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** Type: MMv1 *** -# -# ---------------------------------------------------------------------------- -# -# 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. -# -# ---------------------------------------------------------------------------- - -title 'Test GCP google_bigtableadmin_project_instance_cluster resource.' - -gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') - - project_instance_cluster = input('project_instance_cluster', value: { - "name": "value_name", - "parent": "value_parent", - "location": "value_location", - "state": "value_state", - "default_storage_type": "value_defaultstoragetype" -}, description: 'project_instance_cluster description') -control 'google_bigtableadmin_project_instance_cluster-1.0' do - impact 1.0 - title 'google_bigtableadmin_project_instance_cluster resource test' - - describe google_bigtableadmin_project_instance_cluster(name: project_instance_cluster['name']) do - it { should exist } - its('name') { should cmp project_instance_cluster['name'] } - its('location') { should cmp project_instance_cluster['location'] } - its('state') { should cmp project_instance_cluster['state'] } - its('default_storage_type') { should cmp project_instance_cluster['default_storage_type'] } - - end - - describe google_bigtableadmin_project_instance_cluster(name: "does_not_exit") do - it { should_not exist } - end -end diff --git a/test/integration/verify/controls/google_bigtableadmin_project_instance_clusters.rb b/test/integration/verify/controls/google_bigtableadmin_project_instance_clusters.rb deleted file mode 100644 index 1a84dcb6..00000000 --- a/test/integration/verify/controls/google_bigtableadmin_project_instance_clusters.rb +++ /dev/null @@ -1,33 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** Type: MMv1 *** -# -# ---------------------------------------------------------------------------- -# -# 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. -# -# ---------------------------------------------------------------------------- - -title 'Test GCP google_bigtableadmin_project_instance_clusters resource.' - -gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') - - project_instance_cluster = input('project_instance_cluster', value: { - "name": "value_name", - "parent": "value_parent", - "location": "value_location", - "state": "value_state", - "default_storage_type": "value_defaultstoragetype" -}, description: 'project_instance_cluster description') -control 'google_bigtableadmin_project_instance_clusters-1.0' do - impact 1.0 - title 'google_bigtableadmin_project_instance_clusters resource test' - - describe google_bigtableadmin_project_instance_clusters(parent: project_instance_cluster['parent']) do - it { should exist } - end -end From a0e82acaca96b238cff8c4cd1cc9132d9737e03f Mon Sep 17 00:00:00 2001 From: balasubramanian-s Date: Mon, 1 Jul 2024 19:58:48 +0530 Subject: [PATCH 3/3] added terraform scripts Signed-off-by: balasubramanian-s --- README.md | 1 + docs/resources/google_bigtableadmin_cluster.md | 4 ++-- .../resources/google_bigtableadmin_clusters.md | 4 ++-- libraries/google_bigtableadmin_cluster.rb | 6 +++--- libraries/google_bigtableadmin_clusters.rb | 4 ++-- test/integration/build/gcp-mm.tf | 18 +++++++++++++++++- .../configuration/mm-attributes.yml | 9 +++++++-- 7 files changed, 34 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6d6ba54b..13a06807 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,7 @@ The following resources are available in the InSpec GCP Profile | [google_appengine_standard_app_version](docs/resources/google_appengine_standard_app_version.md) | [google_appengine_standard_app_versions](docs/resources/google_appengine_standard_app_versions.md) | | [google_bigquery_dataset](docs/resources/google_bigquery_dataset.md) | [google_bigquery_datasets](docs/resources/google_bigquery_datasets.md) | | [google_bigquery_table](docs/resources/google_bigquery_table.md) | [google_bigquery_tables](docs/resources/google_bigquery_tables.md) | +| [google_bigtableadmin_cluster](docs/resources/google_bigtableadmin_cluster.md) | [google_bigtableadmin_clusters](docs/resources/google_bigtableadmin_clusters.md) | | [google_billing_project_billing_info](docs/resources/google_billing_project_billing_info.md) | No Plural Resource | | [google_cloud_scheduler_job](docs/resources/google_cloud_scheduler_job.md) | [google_cloud_scheduler_jobs](docs/resources/google_cloud_scheduler_jobs.md) | | [google_cloudbuild_trigger](docs/resources/google_cloudbuild_trigger.md) | [google_cloudbuild_triggers](docs/resources/google_cloudbuild_triggers.md) | diff --git a/docs/resources/google_bigtableadmin_cluster.md b/docs/resources/google_bigtableadmin_cluster.md index cd1036d2..85a82684 100644 --- a/docs/resources/google_bigtableadmin_cluster.md +++ b/docs/resources/google_bigtableadmin_cluster.md @@ -13,13 +13,13 @@ identifier = "inspec/resources/gcp/google_bigtableadmin_cluster Resource" parent = "inspec/resources/gcp" +++ -Use the `google_bigtableadmin_cluster` InSpec audit resource to test the properties of a test a Google ProjectInstanceCluster. +Use the `google_bigtableadmin_cluster` InSpec audit resource to test the properties of a test a Google Cluster. ## Installation {{% inspec_gcp_install %}} ## Syntax -A `google_bigtableadmin_cluster` is used to test a Google ProjectInstanceCluster resource +A `google_bigtableadmin_cluster` is used to test a Google Cluster resource ## Examples ``` diff --git a/docs/resources/google_bigtableadmin_clusters.md b/docs/resources/google_bigtableadmin_clusters.md index d16a1839..46bcfeb1 100644 --- a/docs/resources/google_bigtableadmin_clusters.md +++ b/docs/resources/google_bigtableadmin_clusters.md @@ -13,13 +13,13 @@ identifier = "inspec/resources/gcp/google_bigtableadmin_clusters Resource" parent = "inspec/resources/gcp" +++ -Use the `google_bigtableadmin_clusters` InSpec audit resource to test the properties of a test a Google ProjectInstanceCluster. +Use the `google_bigtableadmin_clusters` InSpec audit resource to test the properties of a test a Google Cluster. ## Installation {{% inspec_gcp_install %}} ## Syntax -A `google_bigtableadmin_clusters` is used to test a Google ProjectInstanceCluster resource +A `google_bigtableadmin_clusters` is used to test a Google Cluster resource ## Examples ``` diff --git a/libraries/google_bigtableadmin_cluster.rb b/libraries/google_bigtableadmin_cluster.rb index 68022d79..d5385391 100644 --- a/libraries/google_bigtableadmin_cluster.rb +++ b/libraries/google_bigtableadmin_cluster.rb @@ -21,9 +21,9 @@ require 'google/bigtableadmin/property/cluster_encryption_config' # A provider to manage bigtableadmin resources. -class BigtableadminProjectInstanceCluster < GcpResourceBase +class BigtableadminCluster < GcpResourceBase name 'google_bigtableadmin_cluster' - desc 'ProjectInstanceCluster' + desc 'Cluster' supports platform: 'gcp' attr_reader :params @@ -57,7 +57,7 @@ def exists? end def to_s - "ProjectInstanceCluster #{@params[:name]}" + "Cluster #{@params[:name]}" end private diff --git a/libraries/google_bigtableadmin_clusters.rb b/libraries/google_bigtableadmin_clusters.rb index ed8adeec..ea70005e 100644 --- a/libraries/google_bigtableadmin_clusters.rb +++ b/libraries/google_bigtableadmin_clusters.rb @@ -14,9 +14,9 @@ # # ---------------------------------------------------------------------------- require 'gcp_backend' -class BigtableadminProjectInstanceClusters < GcpResourceBase +class BigtableadminClusters < GcpResourceBase name 'google_bigtableadmin_clusters' - desc 'ProjectInstanceCluster plural resource' + desc 'Cluster plural resource' supports platform: 'gcp' attr_reader :table diff --git a/test/integration/build/gcp-mm.tf b/test/integration/build/gcp-mm.tf index 958e3b1b..ad64f575 100644 --- a/test/integration/build/gcp-mm.tf +++ b/test/integration/build/gcp-mm.tf @@ -254,6 +254,9 @@ variable "network_attachments" { variable "compute_target_vpn_gateway" { type = any } +variable "bigtable_instance_cluster" { + type = any +} resource "google_compute_ssl_policy" "custom-ssl-policy" { name = var.ssl_policy["name"] @@ -2155,4 +2158,17 @@ resource "google_compute_region_security_policy" "region-sec-policy-basic" { name = "my-sec-policy-basic" description = "basic region security policy" type = "CLOUD_ARMOR" -} \ No newline at end of file +} +resource "google_bigtable_instance" "inspec-test" { + name = var.bigtable_instance_cluster.name + + cluster { + cluster_id = var.bigtable_instance_cluster.cluster + num_nodes = 1 + storage_type = var.bigtable_instance_cluster.storage_type + } + + labels = { + my-label = var.bigtable_instance_cluster.name + } +} diff --git a/test/integration/configuration/mm-attributes.yml b/test/integration/configuration/mm-attributes.yml index 63e208ea..b2584d21 100644 --- a/test/integration/configuration/mm-attributes.yml +++ b/test/integration/configuration/mm-attributes.yml @@ -629,8 +629,8 @@ region_network_endpoint_group: target_service: "us-central1-logging.googleapis.com" apigee_organization_apis: - name : "firstproxy", - parent : "organizations/ppradhan", + name : "firstproxy" + parent : "organizations/ppradhan" api_proxy_type : "PROGRAMMABLE" secrets_manager_v1: @@ -715,3 +715,8 @@ compute_target_ssl_proxy: protocol: "SSL" health_check_name: "health-check" backend_service_name: "backend-service" + +bigtable_instance_cluster: + name: "inspec-test" + cluster: "inspec-test-c1" + storage_type: "SSD"