{"id":18995538,"url":"https://github.com/turbot/steampipe-mod-gcp-labels","last_synced_at":"2026-02-02T12:12:32.464Z","repository":{"id":40418907,"uuid":"396602496","full_name":"turbot/steampipe-mod-gcp-labels","owner":"turbot","description":"Is your GCP labels strategy following best practice? This mod checks if your GCP resource labels are set correctly to help you manage them effectively using Powerpipe and Steampipe.","archived":false,"fork":false,"pushed_at":"2024-10-24T11:46:24.000Z","size":1820,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-01-01T16:23:57.872Z","etag":null,"topics":["gcp","hacktoberfest","labels","powerpipe","powerpipe-mod","steampipe","steampipe-mod","tagging","tags"],"latest_commit_sha":null,"homepage":"https://hub.powerpipe.io/mods/turbot/gcp_labels","language":"Pascal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/turbot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-16T03:39:25.000Z","updated_at":"2024-10-24T11:31:05.000Z","dependencies_parsed_at":"2023-01-28T19:15:19.004Z","dependency_job_id":"1f15708c-e74a-441f-ba9c-11f30a884692","html_url":"https://github.com/turbot/steampipe-mod-gcp-labels","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbot%2Fsteampipe-mod-gcp-labels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbot%2Fsteampipe-mod-gcp-labels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbot%2Fsteampipe-mod-gcp-labels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbot%2Fsteampipe-mod-gcp-labels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/turbot","download_url":"https://codeload.github.com/turbot/steampipe-mod-gcp-labels/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240010509,"owners_count":19733514,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gcp","hacktoberfest","labels","powerpipe","powerpipe-mod","steampipe","steampipe-mod","tagging","tags"],"created_at":"2024-11-08T17:31:27.877Z","updated_at":"2026-02-02T12:12:27.431Z","avatar_url":"https://github.com/turbot.png","language":"Pascal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GCP Labels Mod for Powerpipe\n\nA GCP labels checking tool that can be used to look for unlabeled resources, missing labels, resources with too many labels, and more.\n\nRun checks in a dashboard:\n\n![image](https://raw.githubusercontent.com/turbot/steampipe-mod-gcp-labels/main/docs/gcp_labels_dashboard.png)\n\nOr in a terminal:\n\n![image](https://raw.githubusercontent.com/turbot/steampipe-mod-gcp-labels/main/docs/gcp_labels_mod_terminal.png)\n\n## Documentation\n\n- **[Benchmarks and controls →](https://hub.powerpipe.io/mods/turbot/gcp_labels/controls)**\n\n## Getting Started\n\n### Installation\n\nInstall Powerpipe (https://powerpipe.io/downloads), or use Brew:\n\n```sh\nbrew install turbot/tap/powerpipe\n```\n\nThis mod also requires [Steampipe](https://steampipe.io) with the [GCP plugin](https://hub.steampipe.io/plugins/turbot/gcp) as the data source. Install Steampipe (https://steampipe.io/downloads), or use Brew:\n\n```sh\nbrew install turbot/tap/steampipe\nsteampipe plugin install gcp\n```\n\nSteampipe will automatically use your default GCP credentials. Optionally, you can [setup multiple projects](https://hub.steampipe.io/plugins/turbot/gcp#multi-project-connections).\n\nFinally, install the mod:\n\n```sh\nmkdir dashboards\ncd dashboards\npowerpipe mod init\npowerpipe mod install github.com/turbot/steampipe-mod-gcp-labels\n```\n\n### Browsing Dashboards\n\nStart Steampipe as the data source:\n\n```sh\nsteampipe service start\n```\n\nStart the dashboard server:\n\n```sh\npowerpipe server\n```\n\nBrowse and view your dashboards at **http://localhost:9033**.\n\n### Running Checks in Your Terminal\n\nInstead of running benchmarks in a dashboard, you can also run them within your\nterminal with the `powerpipe benchmark` command:\n\nList available benchmarks:\n\n```sh\npowerpipe benchmark list\n```\n\nRun a benchmark:\n\n```sh\npowerpipe benchmark run gcp_labels.benchmark.unlabeled\n```\n\nDifferent output formats are also available, for more information please see\n[Output Formats](https://powerpipe.io/docs/reference/cli/benchmark#output-formats).\n\n### Configure Variables\n\nSeveral benchmarks have [input variables](https://powerpipe.io/docs/build/mod-variables#input-variables) that can be configured to better match your environment and requirements. Each variable has a default defined in its source file, e.g., `controls/limit.sp`, but these can be overridden in several ways:\n\nIt's easiest to setup your vars file, starting with the sample:\n\n```sh\ncp powerpipe.ppvars.example powerpipe.ppvars\nvi powerpipe.ppvars\n```\nAlternatively you can pass variables on the command line:\n\n```sh\npowerpipe benchmark run gcp_labels.benchmark.mandatory --var 'mandatory_labels=[\"application\", \"environment\", \"department\", \"owner\"]'\n```\n\nOr through environment variables:\n\n```sh\nexport PP_VAR_mandatory_labels='[\"application\", \"environment\", \"department\"]'\npowerpipe benchmark run gcp_labels.benchmark.mandatory\n```\n\nThese are only some of the ways you can set variables. For a full list, please see [Passing Input Variables](https://powerpipe.io/docs/build/mod-variables#passing-input-variables).\n\n### Remediation\n\nUsing the control output and the gcloud CLI, you can remediate various label issues.\n\nFor instance, with the results of the `compute_instance_mandatory` control, you can add missing labels with the gcloud CLI:\n\n```sh\n#!/bin/bash\n\nOLDIFS=$IFS\nIFS='#'\n\nINPUT=$(powerpipe control run compute_instance_mandatory --var 'mandatory_labels=[\"application\"]' --output csv --header=false --separator '#' | grep 'alarm')\n[ -z \"$INPUT\" ] \u0026\u0026 { echo \"No instances in alarm, aborting\"; exit 0; }\n\nwhile read -r group_id title description control_id control_title control_description reason resource status location project\ndo\n  # Get the instance name from the self-link, e.g., https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances/my-instance\n  instance_name=$(echo \"$resource\" | rev | cut -d \"/\" -f1 | rev)\n  gcloud compute instances add-labels \"$instance_name\" --labels=application=my_application --zone=${location}\ndone \u003c\u003c\u003c \"$INPUT\"\n\nIFS=$OLDIFS\n```\n\nTo remove prohibited labels from Compute instances:\n```sh\n#!/bin/bash\n\nOLDIFS=$IFS\nIFS='#'\n\nINPUT=$(powerpipe control run compute_instance_mandatory --var 'prohibited_labels=[\"password\"]' --output csv --header=false --separator '#' | grep 'alarm')\n[ -z \"$INPUT\" ] \u0026\u0026 { echo \"No instances in alarm, aborting\"; exit 0; }\n\nwhile read -r group_id title description control_id control_title control_description reason resource status location project\ndo\n  # Get the instance name from the self-link, e.g., https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances/my-instance\n  instance_name=$(echo \"$resource\" | rev | cut -d \"/\" -f1 | rev)\n  gcloud compute instances remove-labels ${instance_name} --labels=password --zone=${location}\ndone \u003c\u003c\u003c \"$INPUT\"\n```\n\n## Open Source \u0026 Contributing\n\nThis repository is published under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0). Please see our [code of conduct](https://github.com/turbot/.github/blob/main/CODE_OF_CONDUCT.md). We look forward to collaborating with you!\n\n[Steampipe](https://steampipe.io) and [Powerpipe](https://powerpipe.io) are products produced from this open source software, exclusively by [Turbot HQ, Inc](https://turbot.com). They are distributed under our commercial terms. Others are allowed to make their own distribution of the software, but cannot use any of the Turbot trademarks, cloud services, etc. You can learn more in our [Open Source FAQ](https://turbot.com/open-source).\n\n## Get Involved\n\n**[Join #powerpipe on Slack →](https://turbot.com/community/join)**\n\nWant to help but don't know where to start? Pick up one of the `help wanted` issues:\n\n- [Powerpipe](https://github.com/turbot/powerpipe/labels/help%20wanted)\n- [GCP Labels Mod](https://github.com/turbot/steampipe-mod-gcp-labels/labels/help%20wanted)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturbot%2Fsteampipe-mod-gcp-labels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fturbot%2Fsteampipe-mod-gcp-labels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturbot%2Fsteampipe-mod-gcp-labels/lists"}