Configuration Management (CM) - Google Cloud Platform
Overview
Section titled “Overview”This guide provides gcloud commands and automated methods for collecting evidence related to NIST SP 800-53 and FedRAMP Configuration Management (CM) family controls in Google Cloud Platform environments.
Key GCP Services
Section titled “Key GCP Services”- Cloud Asset Inventory: Track and analyze resource configurations
- Organization Policy Service: Enforce configuration constraints
- Deployment Manager: Infrastructure as code templates
- Security Command Center: Configuration compliance monitoring
- Cloud Build: Automated deployment pipelines
Control Implementation Commands
Section titled “Control Implementation Commands”CM-2: Baseline Configuration
Section titled “CM-2: Baseline Configuration”Export current project configuration
gcloud asset export \ --project=PROJECT_ID \ --output-path=gs://BUCKET_NAME/baseline-config.json \ --content-type=resourceList all Compute Engine instance templates
gcloud compute instance-templates list --project=PROJECT_IDExport organization policies
gcloud resource-manager org-policies list \ --organization=ORGANIZATION_ID \ --format=json > org-policies-baseline.jsonCapture VPC configurations
gcloud compute networks list --project=PROJECT_ID --format=jsongcloud compute firewall-rules list --project=PROJECT_ID --format=jsonList all images in project
gcloud compute images list --project=PROJECT_IDExport Deployment Manager deployments
gcloud deployment-manager deployments list --project=PROJECT_IDgcloud deployment-manager deployments describe DEPLOYMENT_NAME --project=PROJECT_IDCM-3: Configuration Change Control
Section titled “CM-3: Configuration Change Control”Monitor configuration changes via audit logs
gcloud logging read \ "protoPayload.methodName:(\"compute.instances.insert\" OR \"compute.firewalls.patch\" OR \"storage.buckets.update\")" \ --project=PROJECT_ID \ --format=json \ --freshness=7dList Cloud Source Repositories
gcloud source repos list --project=PROJECT_IDView Cloud Build history
gcloud builds list --project=PROJECT_ID --limit=50Check deployment history
gcloud deployment-manager deployments list --project=PROJECT_ID --format="table(name,insertTime,operation.status)"CM-5: Access Restrictions for Change
Section titled “CM-5: Access Restrictions for Change”Create custom role for configuration management
gcloud iam roles create configurationManager \ --organization=ORGANIZATION_ID \ --title="Configuration Manager" \ --description="Manages infrastructure configurations" \ --permissions=compute.instances.update,compute.networks.update,storage.buckets.updateList who has deployment permissions
gcloud projects get-iam-policy PROJECT_ID \ --flatten="bindings[].members" \ --filter="bindings.role:(roles/deploymentmanager.editor OR roles/editor OR roles/owner)" \ --format="table(bindings.members,bindings.role)"CM-6: Configuration Settings
Section titled “CM-6: Configuration Settings”List Security Health Analytics findings
gcloud scc findings list organizations/ORGANIZATION_ID \ --source=organizations/ORGANIZATION_ID/sources/SECURITY_HEALTH_ANALYTICS_SOURCE_ID \ --filter="state=\"ACTIVE\""Check Cloud Storage bucket configurations
for bucket in $(gsutil ls); do echo "Bucket: $bucket" gsutil iam get $bucket gsutil uniformbucketlevelaccess get $bucketdoneVerify OS Login is enabled on instances
gcloud compute instances list \ --format="table(name,metadata.items[key='enable-oslogin'].value)" \ --filter="metadata.items.key='enable-oslogin'"Check project-wide metadata
gcloud compute project-info describe --project=PROJECT_ID --format="yaml(commonInstanceMetadata)"CM-7: Least Functionality
Section titled “CM-7: Least Functionality”List enabled APIs
gcloud services list --enabled --project=PROJECT_IDDisable unnecessary APIs
gcloud services disable API_NAME --project=PROJECT_IDFind unused firewall rules
gcloud compute firewall-rules list \ --filter="disabled=true" \ --format="table(name,creationTimestamp,disabled)"List all running services on instances
gcloud compute ssh INSTANCE_NAME --command="systemctl list-units --type=service --state=running"CM-8: Information System Component Inventory
Section titled “CM-8: Information System Component Inventory”Export complete asset inventory
gcloud asset export \ --organization=ORGANIZATION_ID \ --output-path=gs://BUCKET_NAME/inventory-$(date +%Y%m%d).json \ --content-type=resourceQuery specific resource types
gcloud asset search-all-resources \ --scope=organizations/ORGANIZATION_ID \ --asset-types=compute.googleapis.com/Instance,storage.googleapis.com/BucketList resources with specific labels
gcloud compute instances list \ --filter="labels.environment=production" \ --format="table(name,labels.environment,labels.owner,creationTimestamp)"Export all Compute Engine resources
# Instancesgcloud compute instances list --format=json > instances.json
# Disksgcloud compute disks list --format=json > disks.json
# Networksgcloud compute networks list --format=json > networks.json
# Subnetsgcloud compute networks subnets list --format=json > subnets.jsonCM-9: Configuration Management Plan
Section titled “CM-9: Configuration Management Plan”Check organization constraints
gcloud resource-manager org-policies list --organization=ORGANIZATION_IDView specific constraint details
gcloud resource-manager org-policies describe constraints/compute.requireOsLogin \ --organization=ORGANIZATION_IDAutomated Evidence Collection Scripts
Section titled “Automated Evidence Collection Scripts”Complete Configuration Baseline Export
Section titled “Complete Configuration Baseline Export”#!/bin/bash# Export complete configuration baseline
PROJECT_ID="YOUR_PROJECT_ID"ORG_ID="YOUR_ORG_ID"OUTPUT_DIR="config_baseline_$(date +%Y%m%d)"mkdir -p $OUTPUT_DIR
# Organization policiesgcloud resource-manager org-policies list --organization=$ORG_ID --format=json > $OUTPUT_DIR/org_policies.json
# Asset inventorygcloud asset export \ --organization=$ORG_ID \ --output-path=gs://YOUR_BUCKET/$OUTPUT_DIR/full_inventory.json \ --content-type=resource
# Compute configurationsgcloud compute instances list --format=json > $OUTPUT_DIR/instances.jsongcloud compute firewall-rules list --format=json > $OUTPUT_DIR/firewall_rules.jsongcloud compute networks list --format=json > $OUTPUT_DIR/networks.jsongcloud compute instance-templates list --format=json > $OUTPUT_DIR/instance_templates.json
# Storage configurationsgsutil ls -L > $OUTPUT_DIR/storage_buckets.txt
# Enabled APIsgcloud services list --enabled --format=json > $OUTPUT_DIR/enabled_apis.jsonConfiguration Drift Detection
Section titled “Configuration Drift Detection”#!/bin/bash# Detect configuration changes from baseline
BASELINE_DIR="baseline_configs"CURRENT_DIR="current_configs_$(date +%Y%m%d)"mkdir -p $CURRENT_DIR
# Export current configurationsgcloud compute firewall-rules list --format=json > $CURRENT_DIR/firewall_rules.jsongcloud compute instances list --format=json > $CURRENT_DIR/instances.json
# Compare with baselineecho "=== Firewall Rules Changes ==="diff $BASELINE_DIR/firewall_rules.json $CURRENT_DIR/firewall_rules.json
echo "=== Instance Changes ==="diff $BASELINE_DIR/instances.json $CURRENT_DIR/instances.jsonMonitor Configuration Changes
Section titled “Monitor Configuration Changes”#!/bin/bash# Monitor critical configuration changes in last 24 hours
gcloud logging read '(protoPayload.methodName="compute.firewalls.insert" OR protoPayload.methodName="compute.firewalls.patch" OR protoPayload.methodName="compute.firewalls.delete" OR protoPayload.methodName="storage.buckets.update" OR protoPayload.methodName="compute.instances.setMetadata")' \--project=PROJECT_ID \--format="table(timestamp,protoPayload.authenticationInfo.principalEmail,protoPayload.methodName,protoPayload.resourceName)" \--freshness=24hAdditional Resources
Section titled “Additional Resources”Page provenance
Community-maintained guidance. Use the edit link below to propose a sourced correction.
Was this page useful?
Help us prioritize the next improvement.