pulumi / pulumi-ai

222 stars 15 forks source link

Don't use date to "generate" a random resource name #52

Closed pierskarsenbarg closed 9 months ago

pierskarsenbarg commented 10 months ago

Hello!

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

wongstein commented 9 months ago

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

wongstein commented 9 months ago

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

pulumi-bot commented 9 months ago

Cannot close issue:

Please fix these problems and try again.

pulumi-bot commented 9 months ago

Cannot close issue:

Please fix these problems and try again.