You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/iac/concepts/resources/options/import.md
+24-4Lines changed: 24 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,9 +43,11 @@ let server = new aws.ec2.Instance("web-server", {
43
43
{{% /choosable %}}
44
44
{{% choosable language python %}}
45
45
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 %}}
48
49
50
+
```python
49
51
import pulumi_aws as aws
50
52
51
53
group = aws.ec2.SecurityGroup('web-sg',
@@ -194,8 +196,26 @@ resources:
194
196
195
197
For this to work, your Pulumi stack must be configured correctly. In this example, it’s important that the AWS region is correct.
196
198
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 then the resource will be modified to reflect the inputs in your Pulumi program.
200
+
201
+
```console
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
Because of auto-naming, it is common to run into this error 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.
219
+
Because of auto-naming, it is common to run into this import-update 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.
200
220
201
221
Once a resource is successfully imported, remove the `import` option because Pulumi is now managing the resource.
0 commit comments