InSpec GCP (Google Cloud Platform) Resource Pack
For more information on project states and SLAs, see this documentation.
This InSpec resource pack uses the native Google Cloud Platform (GCP) support in InSpec and provides the required resources to write tests for GCP.
This implementation was inspired on the ideas by Martez Reed.
Download the SDK and run the installation:
./google-cloud-sdk/install.shgcloud auth application-default loginIf successful, this should be similar to:
$ cat ~/.config/gcloud/application_default_credentials.json
{
"client_id": "764086051850-6qr4p6gpi6hn50asdr.apps.googleusercontent.com",
"client_secret": "d-fasdfasdfasdfaweroi23jknrmfs;f8sh",
"refresh_token": "1/asdfjlklwna;ldkna'dfmk-lCkju3-yQmjr20xVZonrfkE48L",
"type": "authorized_user"
}While InSpec can use user accounts for authentication, Google Cloud documentation recommends using service accounts.
Console in the Google Cloud.Service Accounts.Create Service Accounts and give the required details.Done.Keys Tab.Add Key.Create New Key.JSON.Create.myproject-1-feb7993e8660.jsonmyproject-1-feb7993e8660.json~/.config/gcloud folder. If the file gets downloaded in the Downloads folder, use the below command.mv ~/Downloads/myproject-1-feb7993e8660.json ~/.config/gcloud/…inspec exec:$ export GOOGLE_APPLICATION_CREDENTIALS='~/.config/gcloud/myproject-1-feb7993e8660.json'If still error comes, please check your IAM roles and permissions.
Since this is an InSpec resource pack, it only defines InSpec resources. It includes example tests only. To easily use the GCP resources in your tests do the following:
$ inspec init profile --platform gcp my-gcp-profile
Create new profile at /Users/spaterson/my-gcp-profile
* Create directory libraries
* Create file README.md
* Create directory controls
* Create file controls/example.rb
* Create file inspec.yml
* Create file attributes.yml
* Create file libraries/.gitkeepinputs.yml to point to your projectgcp_project_id: 'my-gcp-project'The generated inspec.yml file automatically points to the InSpec GCP resource pack:
name: my-gcp-profile
title: My GCP InSpec Profile
version: 0.1.0
inspec_version: '>= 4'
inputs:
- name: gcp_project_id
required: true
description: 'The GCP project identifier.'
depends:
- name: inspec-gcp
url: https://github.com/inspec/inspec-gcp/archive/x.tar.gz
supports:
- platform: gcp(For available inspec-gcp versions, see this list of inspec-gcp versions.)
…The following resources are available in the InSpec GCP Profile
No open issues yet, or sync has not completed.