Assured workloads basics

From google/skills · View interactive version

Assured workloads basics is an AI agent skill from the GitHub repository google/skills. Provisions, inspects, updates, and deletes Google Cloud Assured Workloads V1 compliant folders, CMEK settings, Sovereign Controls by Partners, and service usage restrictions. Use when creating, listing, describing, updating, or deleting an Assured Workloads workload for any compliance regime or data

How to use this skill

Skill file

Google Cloud Assured Workloads Basics (V1 GA)

Validate prerequisites, create Assured Workloads V1 compliant folders, allowlist compliant services, and list, inspect, update, or delete existing workloads using gcloud and the Google Cloud Python Client Libraries (google-cloud-assured-workloads and google-api-python-client).

Usage Attribution

For all gcloud CLI, REST API, and MCP attribution requirements when executing commands with this skill, follow the instructions in Usage Attribution.

Mandatory Guardrails

  1. No Fabrication: Never invent Organization IDs, Billing Account IDs, Folder IDs, Project IDs, Workload IDs, or Compliance Regime enums. Validate parameters with scripts/validate_params.py before running commands.
  2. Regional / Multi-Regional Locations & CLI Surface: Assured Workloads V1 does not support --location=global; always use a regional or multi-regional location compatible with the compliance regime (see references/regimes.md). Never use gcloud compliance-manager commands for Assured Workloads V1 workloads.
  3. Human Confirmation Before Mutation: Read-only operations (list, describe, and scripts/manage_workload_updates.py --action=list) can run immediately after validation, but you must obtain explicit user confirmation before executing any mutating or destructive command (create, restrict_allowed_resources.py, update, manage_workload_updates.py --action=apply, delete, folders delete, or projects delete).
  4. Telemetry Attribution & Regional Endpoints:

Step 0: Prerequisites & Environment Setup

Verify these 5 prerequisites before running Assured Workloads operations:

  1. CLI & Python Libraries: Install the Google Cloud SDK (gcloud — see the Google Cloud SDK Installation Guide) and Python client libraries:

```bash

pip install "google-cloud-assured-workloads>=1.0,<2" "google-api-python-client>=2.0,<3" "google-auth>=2.0,<3"

```

  1. Dual Authentication (CLI + ADC): Authenticate both gcloud and Application Default Credentials (gcloud auth login && gcloud auth application-default login, or gcloud auth activate-service-account --key-file=/path/to/key.json + export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json").
  2. Quota & Admin Project: gcloud config set project {admin_project_id} and gcloud auth application-default set-quota-project {admin_project_id}.
  3. API Enablement: Enable the Assured Workloads API (assuredworkloads.googleapis.com):

```bash

gcloud services enable assuredworkloads.googleapis.com --project={admin_project_id}

```

  1. Organization-Level IAM Roles (organizations/{org_id}):

Workflow 1: Create an Assured Workloads workload (Two-Phase Provisioning)

Phase 1: Validate Parameters & Create Workload (`gcloud assured workloads create`)

  1. Select Regime & Location: Check references/regimes.md for all 45 V1 --compliance-regime enums and valid --location values.
  1. Billing Account Discovery (If Omitted): Never guess a billing account ID. If omitted, run gcloud billing accounts list --filter="open=true" --format="table(name,displayName)" or ask the user for billingAccounts/{billing_id}.
  2. Validate & Create: Validate with python3 scripts/validate_params.py --operation=create ..., surface any warnings, obtain explicit user confirmation, and execute gcloud assured workloads create:

```bash

gcloud assured workloads create \

--organization={org_id} --location={location} \

--display-name="{display_name}" --compliance-regime={compliance_regime} \

--billing-account=billingAccounts/{billing_id} \

[--provisioned-resources-parent=folders/{parent_folder_id}] [--enable-sovereign-controls] \

[--next-rotation-time={next_rotation_time} --rotation-period={rotation_seconds}s] \

[--resource-settings=consumer-project-id={consumer_project_id},consumer-project-name={consumer_project_name},encryption-keys-project-id={kms_project_id},encryption-keys-project-name={kms_project_name},keyring-id={keyring_id}] \

[--partner={partner_enum}] [--partner-permissions=data-logs-viewer=true|false] \

[--partner-services-billing-account=billingAccounts/{partner_billing_id}] \

[--labels=key1=val1,key2=val2] [--external-identifier={external_id}] --format=json

```

Phase 2 (Optional): Allowlist Compliant Services / Enable BigQuery (`google-cloud-assured-workloads`)

```python

from google.api_core.client_options import ClientOptions

from google.cloud import assuredworkloads_v1

client = assuredworkloads_v1.AssuredWorkloadsServiceClient(

client_options=ClientOptions(

api_endpoint=f"{location}-assuredworkloads.googleapis.com"

),

transport="rest",

)

request = assuredworkloads_v1.RestrictAllowedResourcesRequest(

name=f"organizations/{org_id}/locations/{location}/workloads/{workload_id}",

restriction_type=assuredworkloads_v1.RestrictAllowedResourcesRequest.RestrictionType.ALLOW_COMPLIANT_RESOURCES,

)

client.restrict_allowed_resources(request=request)

```

(Supported RestrictionType values: ALLOW_COMPLIANT_RESOURCES, APPEND_COMPLIANT_RESOURCES, or ALLOW_ALL_GCP_RESOURCES).

Workflow 2: List & Describe Assured Workloads workloads (`gcloud`)

Read-only list and describe operations do not require user confirmation after validating with scripts/validate_params.py.

  1. List Workloads (ListWorkloads):

```bash

gcloud assured workloads list --organization={org_id} --location={location} \

[--filter="{filter_expression}"] [--limit={limit}] [--page-size={page_size}] --format=json

```

  1. Describe a Specific Workload (GetWorkload):

```bash

gcloud assured workloads describe {workload_id} --organization={org_id} --location={location} --format=json

```

(Or pass the full resource name organizations/{org_id}/locations/{location}/workloads/{workload_id}).

Workflow 3: Delete an Assured Workloads workload (`DeleteWorkload`)

An Assured Workloads workload cannot be deleted while its provisioned Cloud Resource Manager folder (folders/{folder_id}) or child projects still exist (FAILED_PRECONDITION: Workload is not empty / ERROR_CODE_WORKLOAD_NOT_EMPTY). Never run gcloud assured workloads delete before deleting the provisioned folder and its child projects.

  1. Inspect & Validate: Run gcloud assured workloads describe to identify the provisioned folder (folders/{folder_id}) and child projects ({project_id}), and validate with python3 scripts/validate_params.py --operation=delete --workload-id={workload_id} --organization={org_id} --location={location}.
  2. Confirm & Execute Ordered Deletion Sequence: Obtain explicit user confirmation, then run in strict bottom-up order:

```bash

# Step 1: Delete child projects inside the workload folder first

gcloud projects delete {project_id} --quiet

# Step 2: Delete the provisioned Assured Workloads folder

gcloud resource-manager folders delete {folder_id}

# Step 3: Delete the Assured Workloads workload after folder deletion propagates

gcloud assured workloads delete {workload_id} --organization={org_id} --location={location} --quiet

```

Workflow 4: Update an Assured Workloads workload (`UpdateWorkload` & Compliance Updates)

4A. Update Workload Metadata & Notifications (`gcloud assured workloads update`)

```bash

gcloud assured workloads update {workload_id} --organization={org_id} --location={location} \

[--display-name="{new_display_name}"] [--labels=key1=val1,key2=val2] \

[--violation-notifications-enabled=true|false] [--etag={etag}] --format=json

```

4B. List & Apply Compliance Posture Updates (`updates.list` & `updates.apply`)

gcloud assured workloads does not have a built-in CLI subcommand to list or apply compliance posture updates from the updates sub-resource (gcloud assured workloads update only updates workload metadata). Use scripts/manage_workload_updates.py (--action=list or --action=apply after user confirmation) or googleapiclient.discovery.build against the regional Assured Workloads v1 API (https://{location}-assuredworkloads.googleapis.com):

```python

import time

from google.api_core.client_options import ClientOptions

from googleapiclient import discovery

service = discovery.build(

"assuredworkloads",

"v1",

client_options=ClientOptions(

api_endpoint=f"https://{location}-assuredworkloads.googleapis.com"

),

)

parent = f"organizations/{org_id}/locations/{location}/workloads/{workload_id}"

# 1. List updates and filter for AVAILABLE state

resp = (

service.organizations()

.locations()

.workloads()

.updates()

.list(parent=parent)

.execute()

)

available = [u for u in resp.get("updates", []) if u.get("state") == "AVAILABLE"]

# 2. Apply each AVAILABLE update and poll the returned Long-Running Operation (LRO)

for update in available:

op = (

service.organizations()

.locations()

.workloads()

.updates()

.apply(name=update["name"], body={})

.execute()

)

while not op.get("done", False):

time.sleep(3)

op = (

service.organizations()

.locations()

.operations()

.get(name=op["name"])

.execute()

)

```

Common Error Handling & Troubleshooting (`scripts/diagnose_error.py`)

Never blindly retry deterministic 400 INVALID_ARGUMENT, 403 PERMISSION_DENIED, 404 NOT_FOUND, or FAILED_PRECONDITION errors. Run python3 scripts/diagnose_error.py --error-message="{error_output_text}" to match any error against the full Assured Workloads ErrorInfo.reason catalog.

Troubleshooting `Folder creation was unsuccessful. Please try again.` (LRO Inspection)

When gcloud assured workloads create fails with the generic message Folder creation was unsuccessful. Please try again., do not blindly retry. Inspect the failed Long-Running Operation (LRO) in the same organization and location to retrieve the specific ErrorInfo.reason:

gcloud assured operations list --organization={org_id} --location={location} --format=json
gcloud assured operations describe {operation_id} --organization={org_id} --location={location} --format=json

(Or run python3 scripts/diagnose_error.py --fetch-latest-lro --organization={org_id} --location={location}).

Common Folder Creation Preconditions to Check in the LRO Error:

Reference Documentation

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.