sparse-intern-71089
08/13/2020, 12:30 PMwhite-balloon-205
Name:
to a resource to control the name - and do not have to use the auto-generated names. That would allow you to reference the same name elsewhere.
But you should also be able to get the Name output from a resource as .Name
and use that. That has the benefit also of establishing a dependency between the two resources.
What resource are you trying to get the name of? Can you share a relevant code snippet?able-rose-67471
08/13/2020, 9:04 PMvar frontdoor = new Frontdoor(
"example-name", // will auto suffix with random string.
new FrontdoorArgs
{
ResourceGroupName = ResourceGroup.Name,
EnforceBackendPoolsCertificateNameCheck = false,
RoutingRules = RoutingRules,
BackendPoolLoadBalancings = BackendPoolLoadBalancings,
BackendPoolHealthProbes = new List<FrontdoorBackendPoolHealthProbeArgs>
{
// shortened for brevity..
},
BackendPools = new List<FrontdoorBackendPoolArgs>
{
// shortened for brevity..
},
FrontendEndpoints = new List<FrontdoorFrontendEndpointArgs>
{
new FrontdoorFrontendEndpointArgs
{
Name = "example-endpoint-name",
HostName = "<http://example-name.azurefd.net|example-name.azurefd.net>", // The subdomain here has to match the name of the resource exactly.
CustomHttpsProvisioningEnabled = false,
},
},
});
I can't access the name property of this Frontdoor
resource until it is created even though I need it to create the resource.
Pulumi's auto-naming feature offers me a very convenient uniqueness. I expect to be spinning up many of these environments at the same time and as such their names should be unique. I have tried creating my own random suffix for the name and overriding with that, however, that random was causing the resource to regenerate each time even if the resource hadn't changed.
I could use pulumi's Random
resource provider to create a random string, to use to generate a random name for my Frontdoor
module. However, this seems to just be a workaround and I wondered if there was a nicer way to do it. I'm also unsure of whether or not this may cause me problems in the future with how pulumim uses auto-generated names to manage resource updates.
Here's another snippet that represents my 'workaround'.
var random = new Pulumi.Random.RandomString("random", new Pulumi.Random.RandomStringArgs
{
Length = 5,
});
var frontdoor = new Frontdoor(
"example-name", // will auto suffix with random string.
new FrontdoorArgs
{
Name = $"example-name-{random.Result}",
ResourceGroupName = ResourceGroup.Name,
EnforceBackendPoolsCertificateNameCheck = false,
RoutingRules = RoutingRules,
BackendPoolLoadBalancings = BackendPoolLoadBalancings,
BackendPoolHealthProbes = new List<FrontdoorBackendPoolHealthProbeArgs>
{
// shortened for brevity..
},
BackendPools = new List<FrontdoorBackendPoolArgs>
{
// shortened for brevity..
},
FrontendEndpoints = new List<FrontdoorFrontendEndpointArgs>
{
new FrontdoorFrontendEndpointArgs
{
Name = "example-endpoint-name",
HostName = $"example-name-{random.Result}.<http://azurefd.net|azurefd.net>",
CustomHttpsProvisioningEnabled = false,
},
},
});