Skip to content

feat(onboarding): verify Cloud Manager program via connector (SITES-47815)#2829

Draft
alinarublea wants to merge 1 commit into
mainfrom
feature/sites-47815-cm-onboarding-wiring
Draft

feat(onboarding): verify Cloud Manager program via connector (SITES-47815)#2829
alinarublea wants to merge 1 commit into
mainfrom
feature/sites-47815-cm-onboarding-wiring

Conversation

@alinarublea

Copy link
Copy Markdown
Contributor

Draft — depends on the Cloud Manager connector service (tracked in SITES-47815) being deployed and configured. Opening early for review; it is a no-op until then.

What

During onboarding, api-service derives programId/environmentId purely from a regex on the AEM CS preview hostname (extractDeliveryConfigFromPreviewUrl) — they are never checked against Cloud Manager. CM's private API is not directly reachable from api-service's own network, so this adds a client that invokes a dedicated connector Lambda and best-effort verifies the program before the delivery-config-writer job is queued.

See SITES-47815.

Changes

  • src/support/cloud-manager.jsCloudManagerClient (synchronous Lambda.invoke of the connector via @aws-sdk/client-lambda, already a dependency) + createCloudManagerClient(context). All methods degrade gracefully (never throw to the caller): when CM_CONNECTOR_FUNCTION_NAME is unset, or the invoke fails (e.g. before permissions/config land), verifyProgram returns { verified:false, degraded:true } and onboarding proceeds on the regex-derived values.
  • src/support/utils.jsqueueDeliveryConfigWriter (the post-ack onboarding path, so the call's latency is off the Slack 3s window) verifies the program and stamps additive programVerified telemetry onto the SQS payload.
  • 13 unit tests for the client (enabled state, invoke parse / error / non-JSON, verifyProgram verified / not-verified / degraded, factory).

Why a synchronous invoke (not SQS)

programId/environmentId are needed inline to build the delivery-config-writer payload. The onboarding modal already ack()s before this heavy work, so a few-second call fits. @aws-sdk/client-lambda was already a declared dependency.

Validation

  • npm run lint clean · new client test 13 passing · utils.test.js (123) and the plg-onboarding suite (422) still green — graceful degradation means no behavior change while the connector is unconfigured.

Before un-drafting

The connector service must be deployed and reachable, its invoke permission granted to api-service's role, and CM_CONNECTOR_FUNCTION_NAME set in the deploy env.

Follow-up (not here)

Once verification is trusted, resolve environmentId/authorURL from Cloud Manager instead of the hostname regex — this PR only verifies the program to keep the change small and safe.

🤖 Generated with Claude Code

…7815)

During onboarding, api-service derives programId/environmentId purely from a
regex on the AEM CS preview hostname (extractDeliveryConfigFromPreviewUrl),
never checked against Cloud Manager. CM's private API is not directly
reachable from api-service's own network, so this adds a client that invokes
a dedicated connector Lambda and best-effort verifies the program.

- src/support/cloud-manager.js: CloudManagerClient (sync Lambda.invoke of the
  connector) + createCloudManagerClient(context). Methods degrade gracefully
  (never throw): when CM_CONNECTOR_FUNCTION_NAME is unset or the invoke fails,
  verifyProgram returns { verified:false, degraded:true } and onboarding
  proceeds on the regex-derived values.
- src/support/utils.js: queueDeliveryConfigWriter (post-ack, off the Slack 3s
  window) verifies the program and stamps additive `programVerified` telemetry
  onto the delivery-config-writer SQS payload.
- test: 13 unit tests for the client.

Requires the connector Lambda + its invoke permission and
CM_CONNECTOR_FUNCTION_NAME in the deploy env; until then it is a no-op. Draft.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

This PR will trigger a minor release when merged.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.70968% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/support/cloud-manager.js 98.54% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@alinarublea alinarublea deployed to dev-branches July 15, 2026 18:55 — with GitHub Actions Active
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.

1 participant