What am I doing wrong. I am trying to create a Com...
# general
p
What am I doing wrong. I am trying to create a ComponentResource to wrap an AWS S3 Bucket.
Copy code
import * as s3 from "@pulumi/aws-native/s3";
import * as pulumi from "@pulumi/pulumi";

export class Resource extends pulumi.ComponentResource {
  constructor(
    type: Function,
    name: string,
    args?: pulumi.Inputs,
    opts?: pulumi.ComponentResourceOptions,
    remote?: boolean,
    packageRef?: Promise<string | undefined>,
  ) {
    super(`elk:${type.name}`, name, args, opts, remote, packageRef);
  }
}
export class Bucket extends Resource {
  public bucket: s3.Bucket;
  constructor(
    name: string,
    args: s3.BucketArgs,
    opts?: pulumi.ComponentResourceOptions,
  ) {
    super(Bucket, name, args, opts);
    this.bucket = new s3.Bucket(name, args, { parent: this });
    this.registerOutputs({
      bucket: this.bucket
    })
  }
}
• create (up) works • destroy works However, "replacement" does not work, it fails with AlreadyExists
Copy code
aws-native:s3:Bucket (elkbucket-from-pulumi):
    error: creating resource: operation CREATE failed with "AlreadyExists": elkbucket-from-pulumi already exists (Service: S3, Status Code: 0, Request ID: null)
Actually, I nailed it down. modifying the provider triggers a "replace" operation - but it breaks
modifying a tag, does not
l
If you're making a change that you know needs to be a replacement, but the provider doesn't know that, then you can set the deleteBeforeReplace opt. https://www.pulumi.com/docs/concepts/options/deletebeforereplace/