pulumi / pulumi-synced-folder

A Pulumi component that synchronizes a local folder to Amazon S3, Azure Blob Storage, or Google Cloud Storage.
Apache License 2.0
3 stars 3 forks source link

Enable multiple SyncedFolder resources in programs #11

Closed AaronFriel closed 1 year ago

AaronFriel commented 1 year ago

Fixes a bug in registering child resources of the SyncedFolder component which manifests to users as an error. See:

Users may encounter an error like the following:

error: Duplicate resource URN 'urn:pulumi:dev::synced-folder-aws-yaml::synced-folder:index:S3BucketFolder$aws:s3/bucketObject:BucketObject::index.html'; try giving it a unique name

This error is caused by registering multiple child resources under the same name, in this case index.html. Fixing this by only changing the resource name however introduces a regression, users will would resource deletes and creates like so:

     pulumi:pulumi:Stack                    synced-folder-aws-yaml-dev
     └─ synced-folder:index:S3BucketFolder  synced-folder
 +      ├─ aws:s3:BucketObject              synced-folder-index.html    create
 -      └─ aws:s3:BucketObject              index.html                  delete

To fix this, we use the aliases resource option. This ensures the resource synced-folder-index.html is registered with an alias for the old name index.html, which allows Pulumi to rename the URN instead of planning a create and delete.

Users will encounter an error "Duplicate resource alias" if more than one resource is registered, so an input disableManagedObjectAliases is added to disabling the alias to the legacy name.

t0yv0 commented 1 year ago

Ah that's coming in https://github.com/pulumi/pulumi-synced-folder/issues/7