pulumi / examples

Infrastructure, containers, and serverless apps to AWS, Azure, GCP, and Kubernetes... all deployed with Pulumi
https://www.pulumi.com
Apache License 2.0
2.35k stars 879 forks source link

azure-ts-dynamicresource example fails to enable https #804

Open devployment opened 3 years ago

devployment commented 3 years ago

Following the example I get an error if I try to enable https for the custom domain.

error: The resource format is invalid.

Creating the custom domain works, without https enabled. As soon I try to enable it either on create, or as a change I get the resource format error.

If I use az cdn custom-domain enable-https from the Azure CLI directly on an available custom domain it works with the same same parameter given to cdnClient.customDomains.enableCustomHttps

I guess it's related to https://github.com/Azure/azure-sdk-for-js in general and maybe somehow to this from the CLI. But maybe somebody in here has another idea.

ChrisKlug commented 3 years ago

The reason is that version 5 of @azure/arm-cdn requires an extra parameter to be passed in to enableCustomHttps. A working version looks like this

await cdnClient.customDomains.enableCustomHttps(
    inputs.resourceGroupName,
    inputs.profileName,
    inputs.endpointName,
    this.name,
    {
        customDomainHttpsParameters: {
            certificateSource: "Cdn",
            certificateSourceParameters: {
                certificateType: "Dedicated"
            },
            protocolType: "ServerNameIndication"
        }
    });

I'm not sure how Pulumi handles versions for @azure/XXX dependencies. But I have created a PR that fixes the issue when using version 5. Not sure what happens when using 4.2 though... But until that potentially gets accepted, the above code should fix it!