Overview
The official Shieldome provider (shieldome/shieldome) manages your Shieldome account from the same code that builds your infrastructure. The most useful part is domain verification: the domain, its DNS ownership record and the verification are created in a single apply, so the active checks are enabled without any manual step.
| Name | Type | What it manages |
|---|---|---|
shieldome_site | Resource | A domain the account may scan, and the DNS TXT record that proves ownership |
shieldome_site_verification | Resource | Waits until Shieldome confirms the ownership record |
shieldome_scheduled_scan | Resource | A recurring scan (Gold-tier plan) |
shieldome_scan_profile | Resource | Saved scan settings, including authentication and custom headers |
shieldome_latest_scan | Data source | The newest completed scan of a URL: risk score and finding counts |
Prerequisites
- Terraform 1.0 or later, or OpenTofu
- A Shieldome API key - see API Keys. The key acts as your account: keep it in your secret store, not in the code.
Step 1 - Configure the provider
terraform { required_providers { shieldome = { source = "shieldome/shieldome" version = "~> 0.1" } } } provider "shieldome" {} # reads SHIELDOME_API_KEY from the environment
export SHIELDOME_API_KEY="shd_..." terraform init
tofu init.
Step 2 - Add and verify a domain
Without verification Shieldome runs the passive assessment only (see Domain Verification). The site exposes the exact TXT record to publish; any DNS provider works. With Cloudflare:
resource "shieldome_site" "shop" { domain = "shop.example.com" } resource "cloudflare_record" "shieldome_verify" { zone_id = var.zone_id name = shieldome_site.shop.verify_record_name type = "TXT" content = shieldome_site.shop.verify_record_value } resource "shieldome_site_verification" "shop" { site_id = shieldome_site.shop.id timeout = "15m" # keeps checking while DNS propagates depends_on = [cloudflare_record.shieldome_verify] }
With AWS Route 53 the record is aws_route53_record with records = [shieldome_site.shop.verify_record_value]. Once confirmed, the verification stays active; keep the record in place anyway, as it is your proof of ownership if the site ever needs verifying again.
Step 3 - Schedule scans
resource "shieldome_scheduled_scan" "weekly" { target_url = "https://shop.example.com" scan_type = "both" # vuln | perf | both | api interval_hours = 168 webhook_url = var.slack_webhook excluded_paths = "/cart\n/checkout" depends_on = [shieldome_site_verification.shop] } resource "shieldome_scan_profile" "staging" { name = "staging" target_url = "https://staging.shop.example.com" auth_header = "Bearer ${var.staging_token}" custom_headers = { "X-Scanner-Allow" = var.waf_allow_token } }
Changing scan_type, interval_hours, enabled, the notification targets or the excluded paths updates the schedule in place. See Scheduled Scans and Scan Profiles.
Step 4 - Stop a release on critical findings
data "shieldome_latest_scan" "shop" { target_url = "https://shop.example.com" } resource "terraform_data" "release_gate" { lifecycle { precondition { condition = !data.shieldome_latest_scan.shop.found || data.shieldome_latest_scan.shop.critical == 0 error_message = "shop.example.com has critical findings in its latest Shieldome scan." } } }
target_url must match the URL exactly as it was submitted for scanning. Also available: risk_score, high, medium, low, completed_at and found.
Existing resources
Import what you already set up in the app:
terraform import shieldome_site.shop <site id> terraform import shieldome_scheduled_scan.weekly <schedule id> terraform import shieldome_scan_profile.staging <profile id>
The ids are returned by GET /api/me/allowed-sites, GET /api/scheduled-scans and GET /api/profiles (REST API). Creating a site that already exists in the account fails with a message asking for this import.
shieldome_site removes it from the Terraform state only and prints a warning; open a support ticket to remove it from the account. Schedules and profiles are deleted normally.
Configuration
| Argument | Environment variable | Description |
|---|---|---|
api_key | SHIELDOME_API_KEY | Your API key (sensitive) |
base_url | SHIELDOME_BASE_URL | Defaults to https://app.shieldome.com; set it for a self-hosted installation |
Every argument and attribute is listed in the registry documentation; the source is on GitHub.
auth_header, auth_cookie, custom_headers) are marked sensitive but are stored in the Terraform state, like any provider's secrets. Use an encrypted remote backend.
Troubleshooting
| Problem | Solution |
|---|---|
| the API did not answer with JSON - check api_key and base_url | The API key is wrong, revoked, or for another installation |
| Domain not verified in time | The error names the TXT record Shieldome expects. Check it with dig TXT _shieldome-verify.<domain> and raise timeout if DNS is slow to propagate |
| Site already exists | Import the site instead of creating it (see above) |
| Creating a scheduled scan returns 403 | Scheduled scans need a Gold-tier plan |