Overview
External validation webhooks allow you to run IaC validation on your own infrastructure (GitHub Actions, GitLab CI, Jenkins, etc.) instead of using Cloudgeni’s internal runners.Choose Integration Mode
Three integration modes:- GitHub Actions: Cloudgeni triggers your
workflow_dispatchdirectly. Provide workflow filename. No incoming webhook to handle. - GitLab CI: Cloudgeni triggers your GitLab pipeline with variables. Add a job to
.gitlab-ci.ymlthat runs whenCLOUDGENI_UOW_IDis set. - Custom Webhook: Provide your webhook endpoint URL. Cloudgeni sends signed POST requests. You verify signatures, start asynchronous validation and return
202 Accepted.
Step 1: Configure in Cloudgeni
- Go to: Settings → IaC Repositories → Select integration → Select repository → Configure Webhook
- Choose mode:
- GitHub Actions: Enter workflow filename (e.g.,
terraform-validation.yml) - GitLab Pipeline: No additional config needed - uses
.gitlab-ci.yml - Custom Webhook: Enter webhook endpoint URL
- GitHub Actions: Enter workflow filename (e.g.,
- Copy
CLOUDGENI_WEBHOOK_SECRET - Store securely (GitHub Secrets, GitLab CI/CD Variables, environment variables, etc.)
Step 2: Implementation
- GitHub Actions
- GitLab CI
- Custom Webhook
Cloudgeni triggers your workflow via
workflow_dispatch with uowId and callbackUrl inputs. The uowId is the unique identifier for this validation “unit of work” (UOW).Workflow Requirements
- Run IaC steps:
init,validate, andplan(or equivalent for your IaC tool, we currently support Terraform and Bicep) - Required: The
planstep (orwhat-iffor Bicep) is mandatory whenexecutionFailure=false. - Capture outputs:
stdoutfor init/validate, file for plan JSON - Sign callback payload with
CLOUDGENI_WEBHOOK_SECRET - POST results to
callbackUrl
Example Workflow
This workflow is a template. You must customize the authentication, environment matrix, and Terraform commands (e.g.
init args, variable files) to match your specific infrastructure setup.Step 3: Send Callback Response
- Terraform
- Bicep
After validation completes, send signed results to Cloudgeni.Endpoint: Example command to generate plan JSON:
POST /api/v1/callback/uow/{uow_id} (use callbackUrl from webhook)Headers:Content-Type: application/jsonX-Cloudgeni-Signature-256: sha256=<hex>
executionFailure: Set to true only for complete execution failures (cannot run any validation).- When
executionFailure=true:executionFailureMessageis required,environmentsmust be null or empty. - When
executionFailure=false:environmentsis required,executionFailureMessagemust be null. steps[].datafor plan must be a JSON string, not an object.environmentNameshould match your environment (e.g., “main”, “environments/production”).iacTypemust be “TERRAFORM”.
Full schema: https://ai.cloudgeni.ai/docs → “External Validation Callback”
Signing the Callback
Security Best Practices
1. Protect Your Webhook Secret
1. Protect Your Webhook Secret
- Never commit secrets to version control
- Use environment variables or secret managers
- Rotate secrets periodically through the cloudgeni console
2. Always Verify Signatures
2. Always Verify Signatures
- Reject requests without signatures
- Verify before parsing JSON
- Use timing-safe comparison functions
- Log failed verification attempts
3. Use HTTPS
3. Use HTTPS
- Always use HTTPS for webhook endpoints
- Validate TLS certificates
- Consider IP allowlisting if possible
4. Implement Timeouts
4. Implement Timeouts
- Set reasonable timeouts for callbacks (30-60 seconds)
- Handle network failures gracefully
- Implement retry logic with exponential backoff
5. Validate Payload Schema
5. Validate Payload Schema
- Verify all required fields are present
- Validate data types and formats
- Sanitize inputs before processing