Hi all! I want to import an existing S3 bucket int...
# general
g
Hi all! I want to import an existing S3 bucket into my project. I followed the steps here: https://www.pulumi.com/docs/guides/adopting/import/#adopting-existing-resources. The import command succeeded and I added the output source to my project file. I then run
pulumi up
and during the preview stage I get the error message “error: Preview failed: unable to delete resource... ...as it is currently marked for protection. To unprotect the resource, either remove the
protect
flag from the resource in your Pulumi program and run
pulumi up
or...“. I don’t want to delete it; I want to adopt it. Can anyone help me understand why preview seems to be trying to delete a protected/imported resource?
w
The code and state generated by
pulumi import
includes a resource option with
protect=True
(https://www.pulumi.com/docs/intro/concepts/resources/#protect) Your
pulumi up
is trying to delete the bucket for some reason - I wonder if it’s actually trying to replace it (which includes a delete operation). If you do
pulumi preview --diff
what does it show for the bucket?
g
I get this error: “error: missing required property ‘region’“, but when I run
pulumi config get aws:region
, it returns “us=east-1”
w
If that’s not a typo, that’s an error in the config file. It should return
us-east-1
g
oops, it’s a typo. it does return
us-east-1
w
When you get the missing region error, the error message includes an example on setting the property, can you share that example?
g
> pulumi preview --diff
Previewing update (dev)
View Live: https://app.pulumi.com/patrickburrell/...
pulumipulumiStack: (same)
[urn=...]
error: missing required property ‘region’
Resources:
1 unchanged
>
that’s the entirety of the message
I’m using the aws_native provider. Maybe that is relevant?
w
The aws_native provider has it’s own config so you want to
pulumi config set aws-native:region us-east-1
g
Thank you! It seems obvious now in hindsight, but I didn’t realize the native provider would have its own config. Setting that fixed my issue with the missing region. And since I’m fairly new to Pulumi, I decided to stick with the classic provider for now for the documentation and example advantages. Having removed the native provider, I again tried my adoption of an existing bucket, and all is working as expected. I’ve tried to recreate my original problem (to develop my understanding) and now I can’t get it to fail. 🤦‍♂️ II appreciate your input on all this!
👍 1
b
I have written some code to read EC2 and S3 resources from AWS, and output JSON files that can be utilized for
pulumi import -f
. https://github.com/yjiq150/pulumi-aws-resource-scraper