Skip to content

CICD-399 · Preview environment DNS provisioning ​

Encyclopedia · Preview environments and developer experience · All snippets

Previous · CICD-398 · Next · CICD-400

1. Where it fits ​

  • Placement CI run step or authorized lab terminal.
  • Prerequisites trusted preview controller, disposable environment and scoped identities for external resources.
  • Platforms kubernetes, local-lab.
  • Parameters DNS_ZONE, INGRESS_HOST, PREVIEW_HOST, TTL.

2. Copy the snippet ​

bash
jq -n --arg name "${PREVIEW_HOST:?}" --arg target "${INGRESS_HOST:?}" --argjson ttl "${TTL:-60}" '{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:$name,Type:"CNAME",TTL:$ttl,ResourceRecords:[{Value:$target}]}}]}' > dns-change.json
aws route53 change-resource-record-sets --hosted-zone-id "${DNS_ZONE:?}" --change-batch file://dns-change.json

3. How it works ​

The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate. The command archives or inspects the selected files. Verify the relative paths and file set before using the archive downstream.

4. Verify the result ​

Validate the preview subdomain belongs to the approved zone and wait for the change. Scope IAM to the preview suffix.

Validation syntax-validated (Bash parse). Status definitions.