Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random characters at end of resource name #209

Closed
tmeckel opened this issue Apr 15, 2019 · 3 comments
Closed

Random characters at end of resource name #209

tmeckel opened this issue Apr 15, 2019 · 3 comments

Comments

@tmeckel
Copy link

tmeckel commented Apr 15, 2019

I did a evaluation of Pulumi if it could be a replacement for Terraform in Cloud projects. I was a bit baffled when I discovered that the Pulumi Azure backend adds always 8 random characters to a resource name

Randlen: 8,

func AutoNameWithMaxLength(name string, maxlength int) *tfbridge.SchemaInfo {

and why this is not configurable? Well personally I didn't find a possibility to switch off this behavior. According to the code above and where and how the corresponding function AutoNameWithMaxLength is called, it doesn't look like this could be configured in any way.

So what's the technical background why the Azure Provider adds those random characters?

@lblackstone
Copy link
Member

Hi @tmeckel, you should be able to specify the name of the resource manually by setting the name argument on the resource inputs. See https://pulumi.io/reference/programming-model.html#autonaming for more info on this behavior.

Closing out this issue for now, but feel free to reopen if you have an example where this isn't working.

@lukehoban
Copy link
Member

See also pulumi/pulumi#1518 which tracks adding the ability to suppress auto naming at a more coarse-grained level.

@tmeckel
Copy link
Author

tmeckel commented Apr 15, 2019

@lblackstone , @lukehoban thanks for the quick answers. Highly appreciated!

Can someone add the fact about autonaming more prominently to the official documentation? Even a small hint would be great. 👍 like some TL;DR stuff in the Getting started chapters e.g. https://pulumi.io/quickstart/azure/index.html

I guess this would be very valuable to others because I think when you come from Terraform or another tool to deploy your cloud resources you get quickly confused like me by the default behavior of Pulumi. Especially when I take into account that the name parameter in the costructors for Pulumi Output objects is not the final name and you've to specify the desired name additionally in the name property of the object. Like @lblackstone wrote.

That said, and because the pulumi/pulumi#1518 isn't available right now, I changed my exsiting code e.g. for deploying a resource group from

const rg = new azure.core.ResourceGroup(`rg-${resource_prefix}`,
    { location: "West Europe"} 
);

to

const rg = new azure.core.ResourceGroup(`rg-${resource_prefix}`,
    { 
        name: `rg-${resource_prefix}`,
        location: "West Europe"
    } 
);

Obviously this worked 👍 but now one have to be careful because pulumi up only shows, let's call them the, internal names (those which are specified as the constructor parameter) and not those defined as the name property. If you're not consistent with your naming (different values in constructor and name property) this could lead to other suprises. Will this be addressed by pulumi/pulumi#1518 as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants