Don't use date to "generate" a random resource name
pierskarsenbarg opened this issue Β· comments
Hello!
- Vote on this issue by adding a π reaction
- If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)
Issue details
In this conversation it's using a timestamp to generate a random bucket name:
const bucketForWebsite = new aws.s3.Bucket("websiteBucket", {
acl: "public-read",
bucket: `website-bucket-${Date.now().toString()}`, // A random bucket name, real use may want a more predictable name
policy: JSON.stringify({
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: "*",
Action: "s3:GetObject",
Resource: `arn:aws:s3:::website-bucket-${Date.now().toString()}/*`, // Allow anyone to read all objects from the bucket
}
]
}),
});
Since we have autonaming, we don't need the bucket
input, and probably shouldn't use a timestamp as the name anyway (if we're doing this, why not use the RandomString
resource?
Affected area/feature
I re-created the prompt here: https://www.pulumi.com/ai/conversations/b8c0a481-7b8d-40c9-9c2a-24c9ab075eae
Please let me know if this was an acceptable recreation @pierskarsenbarg
Doing some early analytics, of the 42649 Typescript code blocks Pulumi.ai has created, only 63 have "date." in the code block. Eye balling those 63, about half of them are in comments like " .. update." About 25% are using a date function in some way, but not necessarily for naming resources.
I question if this work is necessary to fix given the very very small impact it will have
Cannot close issue:
- does not have required labels:
resolution/
Please fix these problems and try again.
Cannot close issue:
- does not have required labels:
resolution/
Please fix these problems and try again.