When I create an S3 bucket with Pulumi, a random suffix is added to the specified bucket name. How can I avoid that?
import * as aws from "@pulumi/aws";
// Create an AWS resource (S3 Bucket)
const bucket = new aws.s3.Bucket("my-bucket");
// Export the name of the bucket
export const bucketName = bucket.id;
Mikhail's answer is correct for this specific case for S3 buckets. More generally this behavior is due to the auto-naming functionality within Pulumi. From https://www.pulumi.com/docs/reference/programming-model/#autonaming:
This random postfix is added by default for two reasons. First, it ensures that two instances of a program can be deployed to the same environment without risk of name collisions. Second, it ensures that it will be possible to do zero-downtime replacements when needed, by creating the new resource first, updating any references to point to it, and then deleting the old resource.
This behavior can be overridden per resource by explicitly setting a name
property on the resource (or bucket
in the case of S3 buckets).