Hi, I am attempting to create a set of similar re...
# general
c
Hi, I am attempting to create a set of similar resources within ComponentResource using Azure Native v1.28.0 (in .NET). The
ComponentResource
receives an argument of using the
InputList<T>
where T is a custom class which we manipulate before creating the cloud resources. This means we have to iterate over the
InputList
property and create resources within the
Apply()
block. According to the documentation (https://www.pulumi.com/docs/intro/concepts/inputs-outputs)
“During some program executions, apply doesn’t run. For example, it won’t run during a preview, when resource output values may be unknown. Therefore, you should avoid side-effects within the callbacks. For this reason, you should not allocate new resources inside of your callbacks either, as it could lead to pulumi preview being wrong.”
Is there a better way of doing this, without creating resources within the
Apply()
? Here is a code snippet for some reference.
Copy code
frontendEndpointArgs.Apply(endpoints =>
{
	....
	
	foreach (var frontend in endpoints)
	{
		if (frontend.HttpsConfiguration == null)
		{
			continue;
		}

		var httpsConfigurationArgs = new CustomHttpsConfigurationArgs
		{
			FrontendEndpointId = Output.Format($"/subscriptions/{currentSubscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontend.Name}"),
			CustomHttpsProvisioningEnabled = true,
			CustomHttpsConfigurationConfig = new CustomHttpsConfigurationCustomHttpsConfigurationArgs
			{
				CertificateSource = "AzureKeyVault",
				AzureKeyVaultCertificateVaultId = frontend.HttpsConfiguration.Apply(fe => fe.AzureKeyVaultCertificateVaultId),
				AzureKeyVaultCertificateSecretName = frontend.HttpsConfiguration.Apply(fe => fe.AzureKeyVaultCertificateSecretName),
				AzureKeyVaultCertificateSecretVersion = frontend.HttpsConfiguration.Apply(fe => fe.AzureKeyVaultCertificateSecretVersion),
				//MinimumTlsVersion = "1.2"
			},
		};

		_ = frontend.Name.Apply(frontendName => 
			new CustomHttpsConfiguration($"{frontendName}-SslCertificate", httpsConfigurationArgs, new CustomResourceOptions
			{
				Provider = provider,
				Parent = parent,
			}));
	}

	....
});
t
Hi team, still looking for a good way to achieve resource creation when we need the inputs from a previous section of the pipeline. This is Front Door, but we have other scenarios e.g. creating SQL Server Firewall Rules based on the possible outbound IPs from a web app.