pulumi / pulumi-cloudflare

Pulumi's Cloudflare package, providing multi-language infrastructure as code for Cloudflare
Apache License 2.0
90 stars 11 forks source link

`preview` should catch non-valid CNAME records #748

Closed o-l-a-v closed 2 months ago

o-l-a-v commented 2 months ago

What happened?

preview said "nothing wrong" with a CNAME pointing to https://<fqdn>, notice the https:// part.

Preview should be able to validate that a DNS record is valid. Until this is fixed or added as a feature we'll add this to our linter (PowerShell + powerhell-yaml module).

Example

See "what happened".

Output of pulumi about

Using pulumi/actions@v5 and Pulumi Services/Cloud.

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

iwahbe commented 2 months ago

Hi @o-l-a-v. Thanks for opening an issue. This provider is based on cloud flare's official terraform provider: https://github.com/cloudflare/terraform-provider-cloudflare. We use their validation logic during preview. To proceed, I would open an issue here. As soon as upstream makes the fix, we will reflect it in pulumi-cloudflare.

o-l-a-v commented 2 months ago

Upstream closed with won't fix.


As this might be useful for others later: We do Cloudflare config as YAML, and wrote a linter with PowerShell + the powershell-yaml module. Here's the logic we've used to validate CNAME. Hacky and by no means perfect.

filter Test-ValidCnameValue {
    [OutputType([System.Boolean])]
    Param(
        [Parameter(Mandatory)]
        [string] $Value
    )
    -not [string]::IsNullOrEmpty($Value) -and
    $Value -notmatch '\.{2,}$' -and
    $Value.ToLower() -ceq $Value -and
    [mailaddress]::TryCreate(('test@{0}' -f $Value.TrimEnd('.')),[ref]$null)
}