pulumi-azure-native: Certificate in Use Error after upgrade from AzureNative 2.9 to 3.0
What happened?
I’m testing out the upgrade from Pulumi.AzureNative v2.9 to 3.0, and have run into an unexpected issue.
When deploying to our dev environment, I get the following error:
error: Status=400 Code=“CertificateInUse” Message=“Certificate 'cert-zzzzzzz is used by existing custom domains.” What’s weird is that none of the code we changed as part of the upgrades affects certs… but I suspect it did change the ContainerApp namespace in the pulumi state file, which is causing a “Refresh” update in the Pulumi run.
Before I go deleting the cert and it’s binding in our ingress app, is there something else I might have missed here? We have many, many deployments this will affect, and deleting the binding and the cert and letting it try to recreate these will require taking our production sites down. Not ideal.
Would I be better off to manually edit the state file? (Insert fear emoji here)
/home/runner/work/_actions/pulumi/actions/v6/webpack:/pulumi-github-action/node_modules/@pulumi/pulumi/automation/errors.js:81 : new CommandError(result); ^ CommandError: code: -2 stdout: stderr: Command failed with exit code 255: pulumi up --yes --skip-preview --refresh --diff --exec-agent pulumi/actions@v5 --color auto --exec-kind auto.local --stack dev-eus-00-wil-in1 --non-interactive [resource plugin random-4.18.0] installing [resource plugin azuread-6.4.0] installing [resource plugin random-4.18.1] installing [resource plugin azure-native-2.90.0] installing [resource plugin azure-native-3.2.0] installing error: Status=400 Code=“CertificateInUse” Message=“Certificate ‘cert-zzzzzzz’ is used by existing custom domains.” error: update failed
~ azure-native:app/v20231102preview:Certificate: (refresh) [id=/subscriptions/zzzz/resourceGroups/zzzzz/providers/Microsoft.App/managedEnvironments/cae-zzz/certificates/cert-zzzzzzz] [urn=urn:pulumi:zzzzz::CustomerInstance::azure-native:app/v20231102preview:Certificate::cert-zzzzzzz] [provider=urn:pulumi:zzzzz::CustomerInstance::pulumi:providers:azure-native::zzzzz-azure-provider::fa2165a6-a041-445b-a1af-46260a4d9a66]
Example
Here’s the code we use to create the container. None of this changed with the migration to 3.0… except the namespace on the ContainerApp in the Pulumi package.
var customDomains = GetCustomerDomainArgs(domainCertificates);
var containerApp = new ContainerApp(appsettings.Containers.IadIngress.Name,
new ContainerAppArgs
{
Configuration = new ConfigurationArgs
{
Ingress = new IngressArgs
{
CustomDomains = customDomains,
External = true,
TargetPort = 8080,
AllowInsecure = true,
},
Registries = new RegistryCredentialsArgs
{
Server = registryUrl,
PasswordSecretRef = "registry-secret",
Username = username,
},
Secrets = new SecretArgs
{
Name = "registry-secret",
Value = password,
},
},
ContainerAppName = appsettings.Containers.IadIngress.Name.ToLowerInvariant(),
ManagedEnvironmentId = containerAppsEnvironment.Id,
WorkloadProfileName = deploymentContext.GetWorkloadProfileName(appsettings.Containers.IadIngress.ContainerAppWorkloadProfileName),
ResourceGroupName = resourceGroup.Name,
Identity = new ManagedServiceIdentityArgs { Type = "SystemAssigned" },
Template = new TemplateArgs
{
Containers = new List<ContainerArgs>
{
new()
{
Name = appsettings.Containers.IadIngress.Name,
Image = $"{registryUrl}/{appsettings.Containers.IadIngress.Image}",
Resources = new ContainerResourcesArgs
{
Cpu = appsettings.Containers.IadIngress.Cpu ?? 0.25,
Memory = appsettings.Containers.IadIngress.Memory ?? "0.5Gi",
},
Probes = [
new ContainerAppProbeArgs
{
Type = Pulumi.AzureNative.App.V20231102Preview.Type.Readiness,
HttpGet = new ContainerAppProbeHttpGetArgs
{
Path = "/ready",
Port = 9902,
},
SuccessThreshold = 2,
FailureThreshold = 2,
PeriodSeconds = 10,
TimeoutSeconds = 5,
},
new ContainerAppProbeArgs
{
Type = Pulumi.AzureNative.App.V20231102Preview.Type.Startup,
TcpSocket = new ContainerAppProbeTcpSocketArgs
{
Port = 8080,
},
SuccessThreshold = 1,
FailureThreshold = 18,
PeriodSeconds = 10,
TimeoutSeconds = 5,
},
],
},
},
Scale = new ScaleArgs
{
MinReplicas = 1,
MaxReplicas = 1,
},
},
Tags = deploymentContext.MergeTags(new Dictionary<string, string>
{
{ "container", appsettings.Containers.IadIngress.Name },
{ "image", appsettings.Containers.IadIngress.Image },
}),
},
new CustomResourceOptions { Provider = deploymentContext.Provider });
private CustomDomainArgs[] GetCustomerDomainArgs(IEnumerable<DomainCertificate> domainCertificates)
{
var domains = new List<CustomDomainArgs>();
foreach (var domainCertificate in domainCertificates)
{
domains.Add(new CustomDomainArgs
{
Name = domainCertificate.Domain,
CertificateId = domainCertificate.Certificate.Id,
});
}
return domains.ToArray();
}
Output of pulumi about
‘dotnet build -nologo .’ completed successfully CLI Version 3.106.0 Go Version go1.22.0 Go Compiler gc
Plugins NAME VERSION azure-native 3.2.0 azuread 6.4.0 dotnet unknown random 4.18.1
Host OS Microsoft Windows 11 Pro Version 10.0.22631 Build 22631 Arch x86_64
This project is written in dotnet: executable=‘C:\Program Files\dotnet\dotnet.exe’ version=‘9.0.105’
Backend Name WUS-JBeernink URL file://~ User AzureAD\JoeBeernink Organizations Token type personal
Dependencies: NAME VERSION Azure.Identity 1.13.2 Azure.Security.KeyVault.Secrets 4.7.0 Azure.Storage.Blobs 12.24.0 StyleCop.Analyzers 1.2.0-beta.556
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).
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 16 (6 by maintainers)
hmmm… it would still be helpful if you could attach the verbose logs, but from the snippits you’ve posted, it seems like maybe the
azureApiVersionvalue updating itself is what’s triggering the replace. You could try addingIgnoreChanges = { "azureApiVersion" }to the resource options to see if that avoids the replacement.Tried it with refresh=false and the new PR for the pulumi action, and logs-verbiosity: 9, debug true.
Looks like it is trying to replace the certificate on the CAE… not sure why it would be doing that. It doesn’t seem to do that if I run the non-updated code… but not sure if the stack file is truly compatible with the old 2.9 exe now that the namespaces have been moved around, and I don’t want to muddy the waters further.
To explain why the log line shows “pulumi/actions@v5”, it is an minor display bug: https://github.com/pulumi/actions/pull/1367
Ah, well I can explain the
MetricAlerterror: That resource moved from theinsightspackage to themonitorpackage in v3 (https://www.pulumi.com/registry/packages/azure-native/api-docs/monitor/metricalert/), so it’s unsurprising that the --refresh flag triggers that error. (We need to successfully update with v3 first, before we can refresh using v3.)As for enabling debug logs on pulumi/action: we were apparently missing that option, but just landed a PR to add it! If you pin
pului/actions@9b1afb5b640843185b14588293e4c179af3a0003you should be able to setlog-verbosity: 9anddebug: trueto get the verbose logs in the runner.