I am trying to migrate a set of AWS resources prov...
# general
c
I am trying to migrate a set of AWS resources provisioned by a developer into Pulumi IaC...
pulumi import
works fine for most of the resources, however there are s3 buckets and SQS topics that are provisioned in another AWS account. The
pulumi import -h
shows a
--provider
option:
Copy code
--provider string                       The name and URN of the provider to use for the import in the format name=urn, where name is the variable name for the provider resource
I guess my question is whether I need to first provision this alternate provider in an otherwise empty project and then import the resources? It does not seem I can both add a custom provider and use it in the same run.
Copy code
sgProvider, err := aws.NewProvider(ctx, fmt.Sprintf("provider-%s", cfg.RegionAlias), &aws.ProviderArgs{
      Profile: pulumi.String("default"),
      Region: pulumi.String("ap-southeast-1"),
    })
    if err != nil {
      return err
    }
    emailBucket, err := s3.NewBucket(ctx, "dev-aws-sg-ses-mailbox", &s3.BucketArgs{
      Bucket: pulumi.String("dev-aws-sg-ses-mailbox"),
    }, pulumi.Provider(sgProvider))
    if err != nil {
      return err
    }

...

$ pulumi import aws:s3/bucket:Bucket dev-aws-sg-ses-mailbox dev-aws-sg-ses-mailbox --provider provider-aws-sg="urn:pulumi:common::foo-iac-addon-ses::pulumi:providers:aws::provider-aws-sg"

...

  aws:s3:Bucket (dev-aws-sg-ses-mailbox):
    error: Preview failed: bad provider reference 'urn:pulumi:common::foo-iac-addon-ses::pulumi:providers:aws::provider-aws-sg' for resource urn:pulumi:common::foo-iac-addon-ses::aws:s3/bucket:Bucket::dev-aws-sg-ses-mailbox: urn:pulumi:common::foo-iac-addon-ses::pulumi:providers:aws is not a valid URN
\
e
I guess my question is whether I need to first provision this alternate provider in an otherwise empty project and then import the resources?
Yes Not currently supported to "import" a provider
h
Take this with a grain of salt because I have no clue, but I use multiple providers in Python and have been able to import using the ResourceOptions: https://www.pulumi.com/docs/iac/concepts/options/import/
c
Thanks for the advice all - I will give this a try. 👍