Skip to content

Commit 1bb02ff

Browse files
Correct docs in import with Diff (#16580)
* Correct docs in `import` with Diff The behavior of import changed with pulumi/pulumi#19339, and our docs should reflect the current behavior. * Apply documentation review suggestions - Improve grammar in line 199 by adding comma after 'succeed' - Replace 'import-update' terminology with clearer phrasing on line 220 - Change code block language tag from console to bash on line 201 Co-authored-by: Ian Wahbe <[email protected]> --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Ian Wahbe <[email protected]>
1 parent f52a4c3 commit 1bb02ff

File tree

1 file changed

+24
-4
lines changed
  • content/docs/iac/concepts/resources/options

1 file changed

+24
-4
lines changed

content/docs/iac/concepts/resources/options/import.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ let server = new aws.ec2.Instance("web-server", {
4343
{{% /choosable %}}
4444
{{% choosable language python %}}
4545

46-
```python
47-
# IMPORTANT: Python appends an underscore (`import_`) to avoid conflicting with the keyword.
46+
{{% notes type="info" %}}
47+
Python appends an underscore (`import_`) to avoid conflicting with the keyword.
48+
{{% /notes %}}
4849

50+
```python
4951
import pulumi_aws as aws
5052

5153
group = aws.ec2.SecurityGroup('web-sg',
@@ -194,8 +196,26 @@ resources:
194196
195197
For this to work, your Pulumi stack must be configured correctly. In this example, it’s important that the AWS region is correct.
196198
197-
If the resource’s arguments differ from the imported state, the import will fail. You will receive this message: `warning: inputs to import do not match the existing resource; importing this resource will fail`. Select “details” in the `pulumi up` preview to learn what the differences are. If you try to proceed without correcting the inconsistencies, you will see this message: `error: inputs to import do not match the existing resource`. To fix these errors, make sure that your program computes a state that completely matches the resource to be imported.
199+
If the resource's arguments differ from the imported state, the import will succeed, and the resource will then be modified to reflect the inputs in your Pulumi program.
200+
201+
```bash
202+
$ pulumi preview
203+
Previewing update (dev)
204+
205+
View in Browser (Ctrl+O): https://app.pulumi.com/pulumi/dev-yaml/dev/previews/40504f08-05da-43f7-86dd-9baa812bb9ff
206+
207+
Loading policy packs...
208+
209+
Type Name Plan Info
210+
pulumi:pulumi:Stack dev-yaml-dev
211+
~ └─ aws:s3:Bucket bImport update [diff: ~tags,tagsAll]
212+
213+
Resources:
214+
~ 1 to update
215+
= 1 to import
216+
2 changes. 2 unchanged
217+
```
198218
199-
Because of auto-naming, it is common to run into this error when you import a resources name property. Unless you explicitly specify a name, Pulumi will auto-generate one, which is guaranteed not to match, because it will have a random hex suffix. To fix this problem, explicitly specify the resources name or disable auto-naming [as described here](/docs/iac/concepts/resources/names/#autonaming-configuration). Note that, in the example for the EC2 security group, the name was specified by passing `web-sg-62a569b` as the resources name property.
219+
Because of auto-naming, it is common to see this update during import when you import a resource's name property. Unless you explicitly specify a name, Pulumi will auto-generate one, which is guaranteed not to match, because it will have a random hex suffix. To fix this problem, explicitly specify the resource's name or disable auto-naming [as described here](/docs/iac/concepts/resources/names/#autonaming-configuration). Note that, in the example for the EC2 security group, the name was specified by passing `web-sg-62a569b` as the resource's name property.
200220

201221
Once a resource is successfully imported, remove the `import` option because Pulumi is now managing the resource.

0 commit comments

Comments
 (0)