pulumi / pulumi-azure-native

Azure Native Provider
Apache License 2.0
126 stars 34 forks source link

Creating StaticSiteCustomDomain waits for the TXT validation indefinitely #2296

Open rmaziarka opened 1 year ago

rmaziarka commented 1 year ago

What happened?

When you create StaticSiteCustomDomain for StaticSite it waits until TXT validation is finished. But it won't be finished, because TXT entry is being created in the next step. Scripts wait for the execution indefinitely.

Expected Behavior

Creation of StaticSiteCustomDomain shouldn't wait for the domain validation, and it should proceed without it.

Steps to reproduce

    var staticSiteCustomDomain = new StaticSiteCustomDomain(siteName, new()
    {
        DomainName = "page.com",
        Name = staticSite.Name,
        ResourceGroupName = resourceGroup.Name,
        ValidationMethod = "dns-txt-token",
    });

    var txtRecordSet = new RecordSet(siteName+"-TXT", new()
    {
        RecordType = "TXT",
        RelativeRecordSetName = "",
        ResourceGroupName = resourceGroup.Name,,
        TargetResource = new Pulumi.AzureNative.Network.Inputs.SubResourceArgs
        {
            Id = staticSite.Id,
        },
        TxtRecords = new[]
        {
            new TxtRecordArgs
            {
                Value = new[]
                {
                    staticSiteCustomDomain.ValidationToken
                },
            },
        },
        Ttl = 3600,
        ZoneName = "page.com",
    });

Output of pulumi about

CLI Version 3.57.1 Go Version go1.20.1 Go Compiler gc

Plugins NAME VERSION azure-native 1.94.0 dotnet unknown

Host OS Microsoft Windows 11 Pro Version 10.0.22621 Build 22621 Arch x86_64

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).

danielrbradley commented 1 year ago

I think this is due to Azure's internal resource WaitForCompletion mechanisms. This won't complete until the domain has been validated. This will require a little more investigation to confirm.

It might be possible to skip the wait phase for this resouce - as long as we can get access to the validation token before completion.

Optionally, we might be able to introduce a custom secondary resource which just awaits the completion of the validation - to ensure it's completed correctly.

danielrbradley commented 1 year ago

It seems the Azure CLI has the same default behaviour and has an extra --no-wait argument to change this. As a workaround, you could invoke this via the CLI using the command provider.

rmaziarka commented 1 year ago

Thanks @danielrbradley for the quick look. Right now I just commented StaticSiteCustomDomain and created it manually, but in the long run, it would be great to have this option in Pulumi.

danielrbradley commented 1 year ago

Yup, we'll keep this on the backlog, but would also welcome PRs if anyone wants to look into this further before we get to it.