Skip to content

[GCP-3987] Add GCP issue resolver script (POC) - #244

Draft
sujaysdesai wants to merge 3 commits into
mainfrom
sujay.desai/GCP-3987/gcp-perm-fixer
Draft

[GCP-3987] Add GCP issue resolver script (POC)#244
sujaysdesai wants to merge 3 commits into
mainfrom
sujay.desai/GCP-3987/gcp-perm-fixer

Conversation

@sujaysdesai

@sujaysdesai sujaysdesai commented Aug 27, 2026

Copy link
Copy Markdown

Goal

Add a standalone "GCP issue resolver" script (gcp_issue_resolver.pyz) that re-grants missing IAM permissions on an existing Datadog GCP integration service account, so a customer with a broken/incomplete permission set can fix it without redoing full onboarding.

This branch mirrors an in-progress POC from dan.trujillo (dan.trujillo/GCP-XXXX-gcp-perm-fixer), rebased onto current main. One real conflict was resolved: main had independently gained a CREATE_CUSTOM_ORG_ROLE step (GCP-3851) that also touched integration_quickstart/main.py; Dan's commit replaced the old direct find_or_create_service_account(...) call with a new _resolve_service_account(...) helper that falls back to the same call when no existing account is given, so both changes were merged with nothing dropped. The .pyz artifacts were rebuilt from the merged source via build.sh; all affected test suites pass (integration_quickstart 17, issue_resolver 14, shared 52).

Implementation

…an existing service account

Adds gcp/shared/src/gcp_shared/ensure_permissions.py with helpers for
validating and binding IAM roles, and a new gcp/issue_resolver package
that support engineers can run in Cloud Shell to repair a broken
integration without re-running the full quickstart.

- ensure_permissions.py: is_valid_service_account_email (tightened
  regex to block filter injection), validate_service_account_in_project,
  ensure_service_account_permissions, create_service_account_with_permissions
- issue_resolver: standalone .pyz that accepts an email and one or more
  project IDs, re-applies REQUIRED_ROLES, and refreshes the Datadog
  delegate permission
- integration_quickstart/main.py: _resolve_service_account now accepts
  an existing SA email as an alternative to creating a new one
…se pipeline

Adds a WorkflowReporter-based UI mode to gcp_issue_resolver, mirroring
integration_quickstart's WORKFLOW_ID/env-var contract, so a Datadog UI
"repair permissions" action can drive it the same way it drives service
account creation. The existing CLI mode is unchanged for support engineers.

- main.py: branch on WORKFLOW_ID to run UI mode (workflow type
  gcp-permission-repair) vs. CLI mode; report progress per step
- release.yaml: publish gcp/issue_resolver as a release artifact
- README.md: document both invocation modes
- rebuilt dist/gcp_issue_resolver.pyz, dropping a stale uncommitted
  fix_permissions.py module that had leaked into the previous binary
…for project selection

UI mode now requires ACCOUNT_EMAIL to be set at launch (like WORKFLOW_ID),
instead of pulling the service account email out of the polled workflow
selections. receive_user_selections() now only waits for project_ids.

- main.py: rename EMAIL -> ACCOUNT_EMAIL, validate it up front via
  _resolve_email_from_env() before any workflow calls; rename
  RepairStep.SELECTIONS -> PROJECT_SELECTION
- test_main.py: update UI-mode tests for the new env var and payload shape
- README.md: document ACCOUNT_EMAIL as a launch env var
- rebuilt dist/gcp_issue_resolver.pyz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants