diff --git a/content/blog/autonaming-configuration/index.md b/content/blog/autonaming-configuration/index.md new file mode 100644 index 000000000000..4d41d2bb8c86 --- /dev/null +++ b/content/blog/autonaming-configuration/index.md @@ -0,0 +1,342 @@ +--- +title: "Introducing Customizable Resource Auto-naming in Pulumi" +date: 2025-01-16 +meta_desc: "Discover how to customize Pulumi's resource naming to align with your organization's standards and naming conventions." +meta_image: meta.png +authors: + - mikhail-shilkov +tags: + - features + - releases +social: + twitter: | + 🎉 New in Pulumi: Flexible Resource Auto-naming! + + Finally, full control over your cloud resource names: + ✨ Custom naming patterns + 🎯 Verbatim mode + 🔧 Flexible configuration + + No more compromises between naming standards and uniqueness. + + Read more ⬇️ + linkedin: > + 🚀 We're excited to announce Flexible Resource Auto-naming in Pulumi! + + This highly anticipated feature gives you complete control over how your cloud resources are named across all cloud providers. Whether you want to enforce enterprise naming standards, ensure compliance, or maintain consistent naming patterns - we've got you covered. + + Key capabilities: + - Custom naming patterns with static text, resource information, and random components + - Verbatim mode for exact logical name matching + - Option to disable auto-naming entirely + - Support across all cloud providers + + Ready to try it out? Check out our latest blog post to learn more about this game-changing feature for infrastructure management. +--- + +I'm thrilled to announce that you can now customize how Pulumi names your cloud resources! Our default auto-naming feature has helped thousands of customers successfully manage cloud resources at scale by automatically ensuring unique, conflict-free resource names across their cloud deployments. This robust naming system has been particularly valuable for teams managing multiple environments, handling zero-downtime deployments, and maintaining clear resource organization. Today, we're taking it to the next level by giving you control over how these names are generated. + + + +Over the years, we've heard from many teams using Pulumi that while they love the power and convenience of our auto-naming system, they need it to work with their organization's naming standards - whether that's adding cost center identifiers, following compliance rules, or matching existing naming patterns. The [GitHub issue tracking this feature](https://github.com/pulumi/pulumi/issues/1518) has gathered quite some attention (50 thumbs up!) and lots of great input from the community. + +Today, I'm excited to introduce resource auto-naming configuration. Now you can have the best of both worlds: keep the robustness of Pulumi's auto-naming while making it follow your team's naming conventions. Want your resources to include environment tags? Project prefixes? Random suffixes of specific length? Disable auto-naming entirely? It's all possible now, and it works across all major cloud providers. + +## The Road to Better Resource Naming + +The original [feature request](https://github.com/pulumi/pulumi/issues/1518) I opened in June 2018 when I was a Pulumi customer. It has generated extensive discussion, with users sharing various use cases and requirements. Today, I'm happy to finally close that issue with a solution that addresses the community's needs while maintaining Pulumi's robust resource management capabilities. + +## Introducing Auto-naming Configuration + +With the new auto-naming configuration feature, you now have full control over how Pulumi generates resource names. Here are some common scenarios you can achieve: + +### Disable Auto-naming + +If you want complete control over your resource names, you can disable Pulumi auto-naming entirely: + +```yaml +pulumi:autonaming: + mode: disabled +``` + +In this mode, Pulumi will require you to provide explicit physical names for all resources. + +### Use Logical Names As-Is + +For scenarios where you want Pulumi to copy exactly the logical names to become the physical names, you can use the `verbatim` mode: + +```yaml +pulumi:autonaming: + mode: verbatim +``` + +No random suffixes will be added to the resource names. + +Note, when an update requires replacing the resource, Pulumi's default behavior is to create the new resource and then delete the old resource. However, when using verbatim names or patterns without random components, resources that need to be replaced will be deleted before creating the new resource. This can lead to downtime. + +### Custom Naming Patterns + +Create your own naming patterns that combine static text, resource information, and random elements: + +```yaml +pulumi:autonaming: + pattern: ${project}-${stack}-${name}${alphanum(6)} +``` + +See the [auto-naming configuration documentation](/docs/concepts/resources/names/#auto-naming-configuration) to see the full list of available expressions. + +## See It In Action + +Let's look at a practical example. Say you're creating an S3 bucket and a DynamoDB table in your Pulumi program: + +{{< chooser language "typescript,python,csharp,go,java,yaml" >}} + +{{% choosable language typescript %}} + +```typescript +import * as aws from "@pulumi/aws"; + +// Create an S3 bucket +const bucket = new aws.s3.Bucket("uploads"); + +// Create a DynamoDB table +const table = new aws.dynamodb.Table("users", { + hashKey: "id", + attributes: [{ + name: "id", + type: "S", + }], + billingMode: "PAY_PER_REQUEST", +}); +``` + +{{% /choosable %}} + +{{% choosable language python %}} + +```python +import pulumi_aws as aws + +# Create an S3 bucket +bucket = aws.s3.Bucket("uploads") + +# Create a DynamoDB table +table = aws.dynamodb.Table("users", + hash_key="id", + attributes=[aws.dynamodb.TableAttributeArgs( + name="id", + type="S" + )], + billing_mode="PAY_PER_REQUEST" +) +``` + +{{% /choosable %}} + +{{% choosable language csharp %}} + +```csharp +using Pulumi; +using Pulumi.Aws.S3; +using Pulumi.Aws.DynamoDB; +using Pulumi.Aws.DynamoDB.Inputs; + +return await Deployment.RunAsync(() => +{ + // Create an S3 bucket + var bucket = new Bucket("uploads"); + + // Create a DynamoDB table + var table = new Table("users", new TableArgs + { + HashKey = "id", + Attributes = new[] + { + new TableAttributeArgs + { + Name = "id", + Type = "S" + } + }, + BillingMode = "PAY_PER_REQUEST" + }); +}); +``` + +{{% /choosable %}} + +{{% choosable language go %}} + +```go +package main + +import ( + "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/dynamodb" + "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + // Create an S3 bucket + bucket, err := s3.NewBucket(ctx, "uploads", nil) + if err != nil { + return err + } + + // Create a DynamoDB table + table, err := dynamodb.NewTable(ctx, "users", &dynamodb.TableArgs{ + HashKey: pulumi.String("id"), + Attributes: dynamodb.TableAttributeArray{ + &dynamodb.TableAttributeArgs{ + Name: pulumi.String("id"), + Type: pulumi.String("S"), + }, + }, + BillingMode: pulumi.String("PAY_PER_REQUEST"), + }) + if err != nil { + return err + } + + return nil + }) +} +``` + +{{% /choosable %}} + +{{% choosable language java %}} + +```java +package myproject; + +import com.pulumi.Pulumi; +import com.pulumi.aws.s3.Bucket; +import com.pulumi.aws.dynamodb.Table; +import com.pulumi.aws.dynamodb.TableArgs; +import com.pulumi.aws.dynamodb.inputs.TableAttributeArgs; + +public class App { + public static void main(String[] args) { + Pulumi.run(ctx -> { + // Create an S3 bucket + var bucket = new Bucket("uploads"); + + // Create a DynamoDB table + var table = new Table("users", TableArgs.builder() + .hashKey("id") + .attributes(TableAttributeArgs.builder() + .name("id") + .type("S") + .build()) + .billingMode("PAY_PER_REQUEST") + .build()); + }); + } +} +``` + +{{% /choosable %}} + +{{% choosable language yaml %}} + +```yaml +resources: + # Create an S3 bucket + uploads: + type: aws:s3:Bucket + + # Create a DynamoDB table + users: + type: aws:dynamodb:Table + properties: + hashKey: id + attributes: + - name: id + type: S + billingMode: PAY_PER_REQUEST +``` + +{{% /choosable %}} + +{{< /chooser >}} + +By default, Pulumi would generate names like `uploads-ae26f3b` and `users-4c2dd09`. But let's say you want your resources to follow a pattern that includes your project and stack name. You can configure this in your stack configuration file (`Pulumi..yaml`): + +```yaml +config: + pulumi:autonaming: + pattern: ${project}-${stack}-${name} +``` + +Now when you run `pulumi up`, your resources will be created with predictable names: + +- S3 bucket: `myproject-dev-uploads` +- DynamoDB table: `myproject-dev-users` + +You can also set different patterns for specific providers or resource types: + +```yaml +config: + pulumi:autonaming: + pattern: ${project}-${stack}-${name} + providers: + aws: + resources: + "aws:s3/bucket:Bucket": + pattern: ${name}-${stack}-${alphanum(6)} +``` + +With this configuration, you'll get: + +- S3 bucket: `uploads-dev-x7yz9n` (with a random suffix for global uniqueness) +- DynamoDB table: `myproject-dev-users` (following the default pattern) + +### Configuration Syntax + +The configuration syntax differs slightly depending on where you define it: + +In your project file `Pulumi.yaml`: + +```yaml +config: + pulumi:autonaming: + value: + mode: verbatim +``` + +In your stack configuration file `Pulumi..yaml`: + +```yaml +config: + pulumi:autonaming: + mode: verbatim +``` + +The same applies to other configuration patterns shown above - use the `value:` key in project-level configuration, but omit it in stack-level configuration. + +## Getting Started + +To use the auto-naming configuration feature, you'll need: + +1. Pulumi CLI 3.146.0 or later +2. The following minimum provider versions (as applicable): + - AWS provider 6.66.0 or later + - Azure Native provider 2.78.0 or later + - Azure Classic provider 6.14.0 or later + - Google Cloud Platform provider 8.11.0 or later + - Kubernetes provider 4.20.0 or later + - AWS Cloud Control provider 1.21.0 or later + +Once you have the required versions installed, simply add your desired auto-naming configuration to your Pulumi configuration file. + +For complete documentation and advanced usage scenarios, visit our [resource auto-naming documentation](/docs/intro/concepts/resources/names/#auto-naming-configuration). + +## General Availability + +We're excited to announce that the auto-naming feature is now generally available across our major cloud providers. This release marks an important milestone in Pulumi's evolution, delivering a robust and flexible solution for resource naming. + +Thank you to everyone who participated in the [RFC discussion](https://github.com/pulumi/pulumi/discussions/17592) and the preview period and for providing valuable feedback. Your input has been invaluable in creating a solution that works for diverse use cases while maintaining Pulumi's core strengths. + +If you have any questions or feedback about the resource auto-naming feature, please don't hesitate to reach out to us on GitHub or in the [Pulumi Community Slack](https://slack.pulumi.com). diff --git a/content/blog/autonaming-configuration/meta.png b/content/blog/autonaming-configuration/meta.png new file mode 100644 index 000000000000..4b3e89e01da0 Binary files /dev/null and b/content/blog/autonaming-configuration/meta.png differ diff --git a/content/blog/infrastructure-as-code-resource-naming/index.md b/content/blog/infrastructure-as-code-resource-naming/index.md index 21f61e7b2dc9..563518b86421 100644 --- a/content/blog/infrastructure-as-code-resource-naming/index.md +++ b/content/blog/infrastructure-as-code-resource-naming/index.md @@ -9,6 +9,10 @@ tags: - features --- +{{% notes %}} +We've introduced a new way to customize or disable auto-naming with a configuration option. See [Auto-naming Configuration](/blog/autonaming-configuration/) for more information about all the ways you can customize auto-naming. +{{% /notes %}} + "What's in a name? That which we call a rose by any other name would smell as sweet." William Shakespeare's oft repeated quote was used to help Juliet explain that a "Montague" is worthy of love. Juliet may have underestimated the importance of a name, however, since things didn't work out so well for everyone in Verona! Many customers have questions about "names" in Pulumi -- and in an effort to make sure that things work out better for them than they did for Romeo, here's a quick note on naming! @@ -27,6 +31,10 @@ Second, physical names are used in important ways when we update our resources. ## Controlled Naming +{{% notes %}} +We've introduced a new way to customize or disable auto-naming with a configuration option. See [Auto-naming Configuration](/blog/autonaming-configuration/) for more information about all the ways you can customize auto-naming. +{{% /notes %}} + There are times, however, where precise naming is important. You might need to match an existing environment, or want to explicitly control other behavior. If you know for certain that you want to control the naming yourself, you can indeed override auto-naming. Simply specify the physical name on your resource during creation. Most resources expose a `name` property that may be specified in the argument object to the constructor: ```typescript diff --git a/content/blog/pulumi-recommended-patterns-the-basics/index.md b/content/blog/pulumi-recommended-patterns-the-basics/index.md index 7e478f39e354..7731ffcc561e 100644 --- a/content/blog/pulumi-recommended-patterns-the-basics/index.md +++ b/content/blog/pulumi-recommended-patterns-the-basics/index.md @@ -70,7 +70,7 @@ Now we're all set, so let's dive into writing a Pulumi application. The first thing you'll notice when you write a Pulumi app is that every single resource must have its own name. This *Pulumi resource name*, or a logical resource name if you prefer, is used inside your stack state file to uniquely identify your resources. This name is also what you will find at first when exploring your stack resources in the Pulumi web console. -Depending on the resource type, a second name (a *cloud resource name* or a *physical resource name* if you like) may also be provided. This name will be what is used in your cloud vendor's web console. If this *cloud resource name* is unspecified, Pulumi uses the *Pulumi resource name* and appends a [random suffix](/docs/concepts/resources#autonaming) to it to make it unique. +Depending on the resource type, a second name (a *cloud resource name* or a *physical resource name* if you like) may also be provided. This name will be what is used in your cloud vendor's web console. If this *cloud resource name* is unspecified, Pulumi uses the *Pulumi resource name* and appends a [random suffix](/docs/concepts/resources/names/#autonaming) to it to make it unique. As a recommendation, you should use explicit names for all your *Pulumi resource names* and then let Pulumi determine what the *cloud resource names* should be. Let's explore the benefits: @@ -88,7 +88,8 @@ Along with this recommendation, using a unique prefix in the name of your resour Here are a few links to understand physical names and auto-naming a bit better: -* [Resources and auto-naming](/docs/concepts/resources#autonaming) +* [Resources and auto-naming](/docs/concepts/resources/names/#autonaming) +* [Auto-naming Configuration](/docs/concepts/resources/names/#autonaming-configuration) * [Infrastructure as Code Resource Naming](/blog/infrastructure-as-code-resource-naming/) * [Why do resource names have random hex character suffixes?](/docs/support/faq#why-do-resource-names-have-random-hex-character-suffixes) diff --git a/content/blog/pulumi-release-notes-m64/index.md b/content/blog/pulumi-release-notes-m64/index.md index 55eac7f9d7dd..2671391c5d4c 100644 --- a/content/blog/pulumi-release-notes-m64/index.md +++ b/content/blog/pulumi-release-notes-m64/index.md @@ -194,7 +194,7 @@ class Program ### AWS Native provider supports auto-naming -Most Pulumi providers support [auto-naming for resources](/docs/concepts/resources#autonaming), which makes it easier to have multiple stacks of the same Pulumi program by avoiding naming conflicts, among other benefits. Now, our AWS Native provider joins the club with full auto-naming support. +Most Pulumi providers support [auto-naming for resources](/docs/concepts/resources/names/#autonaming), which makes it easier to have multiple stacks of the same Pulumi program by avoiding naming conflicts, among other benefits. Now, our AWS Native provider joins the club with full auto-naming support. [Learn more about AWS auto-naming in this GitHub issue](https://github.com/pulumi/pulumi-aws-native/issues/156) diff --git a/content/docs/iac/concepts/how-pulumi-works.md b/content/docs/iac/concepts/how-pulumi-works.md index 18a4bb92223f..1ffb86178cad 100644 --- a/content/docs/iac/concepts/how-pulumi-works.md +++ b/content/docs/iac/concepts/how-pulumi-works.md @@ -184,7 +184,7 @@ stack mystack - aws.s3.BucketV2 "content-bucket125ce" ``` -Note the extra suffixes on the end of these bucket names. This is due to a process called [auto-naming](/docs/concepts/resources#autonaming), which Pulumi uses by default in order to allow you to deploy multiple copies of your infrastructure without creating name collisions for resources. This behavior can be disabled if desired. +Note the extra suffixes on the end of these bucket names. This is due to a process called [auto-naming](/docs/concepts/resources/names/#autonaming), which Pulumi uses by default in order to allow you to deploy multiple copies of your infrastructure without creating name collisions for resources. This behavior can be disabled if desired. Now, let's make a change to one of resources and run `pulumi up` again. Since Pulumi operates on a desired state model, it will use the last deployed state to compute the minimal set of changes needed to update your deployed infrastructure. For example, imagine that we wanted to add tags to the S3 `media-bucket`. We change our program to express this new desired state: @@ -461,7 +461,7 @@ This time, the engine will not need to make any changes to `media-bucket` since Pulumi executes resource operations in parallel whenever possible, but understands that some resources may have dependencies on other resources. If an [output](/docs/concepts/inputs-outputs/) of one resource is provided as an input to another, the engine records the dependency between these two resources as part of the state and uses these when scheduling operations. This list can also be augmented by using the [dependsOn](/docs/concepts/resources#dependson) resource option. -By default, if a resource must be replaced, Pulumi will attempt to create a new copy of the resource before destroying the old one. This is helpful because it allows updates to infrastructure to happen without downtime. This behavior can be controlled by the [deleteBeforeReplace](/docs/concepts/resources#deletebeforereplace) option. If you have disabled [auto-naming](/docs/concepts/resources#autonaming) by providing a specific name for a resource, it will be treated as if it was marked as `deleteBeforeReplace` automatically (otherwise the create operation for the new version would fail since the name is in use). +By default, if a resource must be replaced, Pulumi will attempt to create a new copy of the resource before destroying the old one. This is helpful because it allows updates to infrastructure to happen without downtime. This behavior can be controlled by the [deleteBeforeReplace](/docs/concepts/resources#deletebeforereplace) option. If you have disabled [auto-naming](/docs/concepts/resources/names/#autonaming) using configuration or by providing a specific name for a resource, it will be treated as if it was marked as `deleteBeforeReplace` automatically (otherwise the create operation for the new version would fail since the name is in use). ## Declarative and imperative approach diff --git a/content/docs/iac/concepts/options/import.md b/content/docs/iac/concepts/options/import.md index 444e6d060ea2..aeee20f32cc4 100644 --- a/content/docs/iac/concepts/options/import.md +++ b/content/docs/iac/concepts/options/import.md @@ -213,6 +213,6 @@ For this to work, your Pulumi stack must be configured correctly. In this exampl If the resource’s arguments differ from the imported state, the import will fail. You will receive this message: `warning: inputs to import do not match the existing resource; importing this resource will fail`. Select “details” in the `pulumi up` preview to learn what the differences are. If you try to proceed without correcting the inconsistencies, you will see this message: `error: inputs to import do not match the existing resource`. To fix these errors, make sure that your program computes a state that completely matches the resource to be imported. -Because of auto-naming, it is common to run into this error when you import a resource’s name property. Unless you explicitly specify a name, Pulumi will auto-generate one, which is guaranteed not to match, because it will have a random hex suffix. To fix this problem, explicitly specify the resource’s name [as described here](/docs/iac/concepts/resources/names/#autonaming). Note that, in the example for the EC2 security group, the name was specified by passing `web-sg-62a569b` as the resource’s name property. +Because of auto-naming, it is common to run into this error when you import a resource’s name property. Unless you explicitly specify a name, Pulumi will auto-generate one, which is guaranteed not to match, because it will have a random hex suffix. To fix this problem, explicitly specify the resource’s name or disable auto-naming [as described here](/docs/iac/concepts/resources/names/#autonaming-configuration). Note that, in the example for the EC2 security group, the name was specified by passing `web-sg-62a569b` as the resource’s name property. Once a resource is successfully imported, remove the `import` option because Pulumi is now managing the resource. diff --git a/content/docs/iac/concepts/resources/_index.md b/content/docs/iac/concepts/resources/_index.md index 736387289688..c925f6c4c182 100644 --- a/content/docs/iac/concepts/resources/_index.md +++ b/content/docs/iac/concepts/resources/_index.md @@ -125,7 +125,7 @@ resources: {{< /chooser >}} -All resources have a required [`name`](/docs/concepts/resources/names) argument, which must be unique across resources of the same kind in a [`stack`](/docs/concepts/stack). This *logical name* influences the *physical name* assigned by your infrastructure’s cloud provider. Pulumi [auto-names](/docs/concepts/resources/names#autonaming) physical resources by default, so the physical name and the logical name may differ. This auto-naming behavior can be overridden, if required. +All resources have a required [`name`](/docs/concepts/resources/names) argument, which must be unique across resources of the same kind in a [`stack`](/docs/concepts/stack). This *logical name* influences the *physical name* assigned by your infrastructure’s cloud provider. Pulumi [auto-names](/docs/concepts/resources/names/#autonaming) physical resources by default, so the physical name and the logical name may differ. This auto-naming behavior can be overridden, if required. The `args` argument is an object with a set of named property input values that are used to initialize the resource. These can be normal raw values—such as strings, integers, lists, and maps—or [outputs](/docs/concepts/inputs-outputs/) from other resources. Each resource has a number of named input properties that control the behavior of the resulting infrastructure. To determine what arguments a resource supports, refer to that resource’s API documentation in the [Registry](/registry/). diff --git a/content/docs/iac/concepts/resources/names.md b/content/docs/iac/concepts/resources/names.md index f76dedc0d998..d5b687a78226 100644 --- a/content/docs/iac/concepts/resources/names.md +++ b/content/docs/iac/concepts/resources/names.md @@ -19,7 +19,7 @@ aliases: Each resource in Pulumi has a [logical name](#logicalname) and a [physical name](#autonaming). The logical name is how the resource is known inside Pulumi, and establishes a notion of identity within Pulumi even when the physical resource might need to change (for example, during a replacement). The physical name is the name used for the resource in the cloud provider that a Pulumi program is deploying to. -Pulumi [auto-names](#autonaming) most resources by default, using the logical name and a random suffix to construct a unique physical name for a resource. Users can provide explicit names to override this default. +Pulumi [auto-names](#autonaming) most resources by default, using the logical name and a random suffix to construct a unique physical name for a resource. Users can provide explicit names to override this default. Users can also [customize or disable auto-naming](#autonaming-configuration) globally, per provider, or per resource type. Each resource also has a [Uniform Resource Name (URN)](#urns) which is a unique name derived from both the logical name of the resource and the type of the resource and, in the case of components, its parents. @@ -279,6 +279,127 @@ resources: {{< /chooser >}} +## Configuring Auto-Naming {#autonaming-configuration} + +You can customize how Pulumi generates resource names through the `pulumi:autonaming` configuration setting. This can be set at the stack, project, or organization level. + +{{% notes %}} +When configuring auto-naming in your project configuration (`Pulumi.yaml`), you need to wrap the configuration in a `value` key: + +```yaml +config: + pulumi:autonaming: + value: + mode: verbatim +``` + +However, when configuring it in a stack configuration file (`Pulumi..yaml`), you can specify the configuration directly: + +```yaml +config: + pulumi:autonaming: + mode: verbatim +``` + +{{% /notes %}} + +Here are the key ways to configure auto-naming: + +### Default Auto-Naming + +The default behavior adds a random suffix to resource names: + +```yaml +config: + pulumi:autonaming: + mode: default +``` + +This is equivalent to having no configuration at all. + +### Verbatim Names + +To use the logical name exactly as specified, without any modifications: + +```yaml +config: + pulumi:autonaming: + mode: verbatim +``` + +No random suffixes will be added to the resource names. + +### Disable Auto-Naming + +To require explicit names for all resources: + +```yaml +config: + pulumi:autonaming: + mode: disabled +``` + +### Custom Naming Pattern + +You can specify a template pattern for generating names: + +```yaml +config: + pulumi:autonaming: + pattern: ${name}-${hex(8)} +``` + +The following expressions are supported in patterns: + +| Expression | Description | Example | +| :---- | :---- | :---- | +| name | Logical resource name | ${name} | +| hex(n) | Hexadecimal random string of length n | ${name}-${hex(5)} | +| alphanum(n) | Alphanumeric random string of length n | ${name}${alphanum(4)} | +| string(n) | Random string of letters of length n | ${name}${string(6)} | +| num(n) | Random string of digits of length n | ${name}${num(4)} | +| uuid | UUID | ${uuid} | +| organization | Organization name | ${organization}_${name} | +| project | Project name | ${project}_${name} | +| stack | Stack name | ${stack}_${name} | +| config.key | Config value of key | ${config.region}_${name} | + +{{% notes type="warning" %}} +When an update requires replacing the resource, Pulumi's default behavior is to create the new resource and then deleting the old resource. However, when using verbatim names or patterns without random components, resources that need to be replaced will be deleted before creating the new resource. This can lead to downtime. +{{% /notes %}} + +### Provider-Specific Configuration + +You can configure auto-naming differently for specific providers or resource types: + +```yaml +config: + pulumi:autonaming: + mode: default + providers: + aws: + pattern: ${name}_${hex(4)} # AWS resources use underscore and shorter suffix + azure-native: + mode: verbatim # Azure resources use exact names + resources: + "azure-native:storage:Account": ${name}${string(6)} # Storage accounts need unique names +``` + +### Strict Name Pattern Enforcement + +By default, providers may modify the generated names to comply with resource-specific requirements. To prevent this and enforce your exact pattern: + +```yaml +config: + pulumi:autonaming: + pattern: ${name}-${hex(8)} + enforce: true +``` + +### Migration + +Changing the autonaming setting on an existing stack doesn't cause any immediate changes. It will only affect any newly created resources on this stack, including resources being replaced for unrelated reasons. To re-create resources with new names, e.g. on a dev stack, you would need to destroy the stack and update it again. + ## Resource Types {#types} Each resource is an instance of a specific Pulumi resource type. This type is specified by a type token in the format `::`. Concrete examples of this format are: diff --git a/content/docs/iac/support/faq.md b/content/docs/iac/support/faq.md index dfa686712619..95a52beb8050 100644 --- a/content/docs/iac/support/faq.md +++ b/content/docs/iac/support/faq.md @@ -37,7 +37,9 @@ Pulumi resources have different logical names and physical names. The logical na To ensure that as many logical Pulumi resources and stacks can be stood up side-by-side without them conflicting, Pulumi automatically creates each resource's name by combining the logical name with a random suffix appended afterwards. This approach to auto-naming also ensures Pulumi can replace resources with less downtime, by creating the replacement before needing to delete the old resource. In practice, both of these provide significant benefits. This means, however, that your resource's physical name will typically look like `my-bucket-d7c2fa0` instead of `my-bucket`. -You can disable this [auto-naming](/docs/concepts/resources#autonaming) on a per-resource basis if this isn't right for you. Doing so lets you have precise physical names without random suffixes, but also means you lose the two benefits named above. +You can disable this [auto-naming](/docs/concepts/resources/names/#autonaming) on a per-resource basis if this isn't right for you. Doing so lets you have precise physical names without random suffixes, but also means you lose the two benefits named above. + +You can also use project or stack configuration to customize or disable auto-naming globally, per provider, or per resource type. See [Auto-naming Configuration](/docs/concepts/resources/names/#autonaming-configuration) for more information. ## Secrets