百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
I

inspec-gcp

> 编程语言
开源

InSpec GCP (Google Cloud 平台)资源包

156 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

InSpec GCP (Google Cloud 平台)资源包

InSpec GCP (Google Cloud Platform) Resource Pack

  • Project State-: Maintained

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.

Prerequisites

Install and configure the Google cloud SDK*

Download the SDK and run the installation:

./google-cloud-sdk/install.sh

Create credentials file via:

bash
gcloud auth application-default login

If successful, this should be similar to:

bash
$ 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.

Create Service Accounts

  1. Go to Console in the Google Cloud.
  2. Click on Service Accounts.
  3. Click on Create Service Accounts and give the required details.
  4. Click on Done.
  5. Now Click on Keys Tab.
  6. Click on Add Key.
  7. Click on Create New Key.
  8. Select the Key type as JSON.
  9. Click on Create.
  10. The Service Account Key will be downloaded. For example: myproject-1-feb7993e8660.jsonmyproject-1-feb7993e8660.json
  11. Move the key to the ~/.config/gcloud folder. If the file gets downloaded in the Downloads folder, use the below command.
bash
mv ~/Downloads/myproject-1-feb7993e8660.json ~/.config/gcloud/
  1. The json credential file for a service account looks like this:
…
  1. Now Setup the environmental variable for the 'GOOGLE_APPLICATION_CREDENTIALS'. And InSpec can be instructed to use it by setting this ENV variable prior to running inspec exec:
bash
$ export GOOGLE_APPLICATION_CREDENTIALS='~/.config/gcloud/myproject-1-feb7993e8660.json'

NOTE:

If still error comes, please check your IAM roles and permissions.

Enable the appropriate APIs that you want to use:

  • Enable Compute Engine API
  • Enable Kubernetes Engine API

Use the resources

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:

Create a new profile for GCP

bash
$ 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/.gitkeep

Update inputs.yml to point to your project

yaml
gcp_project_id: 'my-gcp-project'

The generated inspec.yml file automatically points to the InSpec GCP resource pack:

yaml
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.)

Run the tests

…

Resource documentation

The following resources are available in the InSpec GCP Profile

InSpec GCP Supported Resources https://www.inspec.io/docs/reference/resources/#gcp-resources
Singular Resource Plural Resource
google_access_context_manager_access_level google_access_context_manager_access_levels
google_access_context_manager_access_policy google_access_context_manager_access_policies
google_access_context_manager_service_perimeter google_access_context_manager_service_perimeters
google_apigee_endpoint_attachment google_apigee_endpoint_attachments
google_apigee_organization_envgroup google_apigee_organization_envgroups
google_apigee_organization_instance_attachment google_apigee_organization_instance_attachments
google_apigee_organization_envgroup_attachment google_apigee_organization_envgroup_attachments
google_appengine_standard_app_version google_appengine_standard_app_versions
google_bigquery_dataset google_bigquery_datasets
google_bigquery_table google_bigquery_tables
google_bigtableadmin_cluster google_bigtableadmin_clusters
google_bigtableadmin_instance_app_profile google_bigtableadmin_instance_app_profiles
google_billing_project_billing_info No Plural Resource
google_cloud_scheduler_job google_cloud_scheduler_jobs
google_cloudbuild_trigger google_cloudbuild_triggers
google_cloudfunctions_cloud_function google_cloudfunctions_cloud_functions
google_composer_project_location_environment google_composer_project_location_environments
google_compute_address google_compute_addresses
google_compute_autoscaler google_compute_autoscalers
google_compute_backend_bucket No Plural Resource
google_compute_backend_service google_compute_backend_services
google_compute_disk google_compute_disks
google_compute_disk_type google_compute_disk_types
google_data_loss_prevention_inspect_template google_data_loss_prevention_inspect_templates
google_compute_external_vpn_gateway google_compute_external_vpn_gateways
google_compute_firewall google_compute_firewalls
google_compute_forwarding_rule google_compute_forwarding_rules
google_compute_global_address google_compute_global_addresses
google_compute_global_forwarding_rule [google_compute_globa

Issues· 81 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubygcpinspec

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言