google_sql_database_instances resource
Use the google_sql_database_instances InSpec audit resource to to test a Google Cloud DatabaseInstance resource.
Examples
describe google_sql_database_instances(project: 'chef-gcp-inspec') do
its('instance_states') { should include 'RUNNABLE' }
its('instance_names') { should include 'my-database' }
end
Test that there are no more than a specified number of zones available for the project
describe google_sql_database_instances(project: 'chef-inspec-gcp') do
its('count') { should be <= 100}
end
Test that a database instance exists in the expected zone
describe google_sql_database_instances(project: 'chef-inspec-gcp') do
its('instance_zones') { should include "us-east1-b" }
end
Test that a database instance exists in the expected region
describe google_sql_database_instances(project: 'chef-inspec-gcp') do
its('instance_regions') { should include "us-east1" }
end
Confirm that at least one database instance is in “RUNNABLE” state
describe google_sql_database_instances(project: 'chef-inspec-gcp') do
its('instance_states') { should include "RUNNABLE" }
end
Test that a subset of all database instances matching “mysqldb” are all version “MYSQL_5_7”
google_sql_database_instances(project: 'chef-inspec-gcp').where(instance_name: /mysqldb/).instance_names.each do |instance_name|
describe google_sql_database_instance(project: 'chef-inspec-gcp', database: instance_name) do
it { should exist }
its('database_version') { should eq "MYSQL_5_7" }
end
end
Properties
Properties that can be accessed from the google_sql_database_instances resource:
See google_sql_database_instance for more detailed information.
backend_types: an array ofgoogle_sql_database_instancebackend_typekinds: an array ofgoogle_sql_database_instancekindconnection_names: an array ofgoogle_sql_database_instanceconnection_nameinstance_versions: an array ofgoogle_sql_database_instancedatabase_versionfailover_replicas: an array ofgoogle_sql_database_instancefailover_replicainstance_types: an array ofgoogle_sql_database_instanceinstance_typeip_addresses: an array ofgoogle_sql_database_instanceip_addressesipv6_addresses: an array ofgoogle_sql_database_instanceipv6_addressmaster_instance_names: an array ofgoogle_sql_database_instancemaster_instance_namemax_disk_sizes: an array ofgoogle_sql_database_instancemax_disk_sizeinstance_names: an array ofgoogle_sql_database_instancenameinstance_regions: an array ofgoogle_sql_database_instanceregionreplica_configurations: an array ofgoogle_sql_database_instancereplica_configurationsettings: an array ofgoogle_sql_database_instancesettingsinstance_zones: an array ofgoogle_sql_database_instancegce_zoneinstance_states: an array ofgoogle_sql_database_instancestatedisk_encryption_configurations: an array ofgoogle_sql_database_instancedisk_encryption_configurationdisk_encryption_statuses: an array ofgoogle_sql_database_instancedisk_encryption_statusserver_ca_certs: an array ofgoogle_sql_database_instanceserver_ca_cert
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 SQL Admin API is enabled for the current project.