I'm trying to create two separate buckets in a stack, but when I try and write a file to the second bucket with the same name as any file in the first I get an error
error: Duplicate resource URN 'urn:pulumi:dev::quickstart::aws:s3/bucketObject:BucketObject::index.html'; try giving it a unique name
The code below demonstrates the problem.
Obviously there's no clash as far as AWS is concerned, but is there a different 'name' I should be defining to prevent Pulumi creating what appears to be a duplicate key?
using Pulumi;
using Pulumi.Aws.S3;
class MyStack : Stack
{
public MyStack()
{
// Create an AWS resource (S3 Bucket)
var bucket1 = new Bucket("my-bucket");
var bucketObject1 = new BucketObject("index.html", new BucketObjectArgs {
Bucket = bucket1.BucketName,
Content = "HTML in 1"
});
var bucket2 = new Bucket("my-bucket2");
var bucketObject2 = new BucketObject("index.html", new BucketObjectArgs {
Bucket = bucket2.BucketName,
Content = "HTML in 2"
});
}
}
You should give unique logical names to all resources, including two
BucketObject
's. Logical names are used by Pulumi to identify resources in a stack.You can still give the same physical name to both files: