EC2 - Unable to import Instance
See original GitHub issueHello!
- Vote on this issue by adding a 👍 reaction
- To contribute a fix for this issue, leave a comment (and link to your pull request, if you’ve opened one already)
Steps to reproduce
- In AWS, create a new EC2 instance (and stop it eventually)
- Create a new Pulumi project and stack (I used typescript) and set the region to the region used to create your EC2 instance
- Run the following command to import the instance into your project
pulumi import aws:ec2/instance:Instance TestInstance i-0e122bd18c42c7373
Expected: The resource is imported into the stack, TypeScript code is generated. Actual: The command fails to complete. Output below.
~$ pulumi import aws:ec2/instance:Instance TestInstance i-0e122bd18c42c7373
Previewing import (dev)
View Live: <removed>
Type Name Plan Info
+ pulumi:pulumi:Stack pulumi-import-dev create 1 error
= └─ aws:ec2:Instance TestInstance import 4 errors
Diagnostics:
pulumi:pulumi:Stack (pulumi-import-dev):
error: preview failed
aws:ec2:Instance (TestInstance):
error: aws:ec2/instance:Instance resource 'TestInstance' has a problem: AtLeastOne: "instance_type": one of `instance_type,launch_template` must be specified. Examine values at 'Instance.InstanceType'.
error: aws:ec2/instance:Instance resource 'TestInstance' has a problem: AtLeastOne: "launch_template": one of `ami,instance_type,launch_template` must be specified. Examine values at 'Instance.LaunchTemplate'.
error: aws:ec2/instance:Instance resource 'TestInstance' has a problem: AtLeastOne: "ami": one of `ami,launch_template` must be specified. Examine values at 'Instance.Ami'.
error: Preview failed: one or more inputs failed to validate
Environment:
- Debian 10 (up to date)
- Pulumi 3.10.2
- NodeJS v16.6.0
- Npm modules
pulumi-import@ /<removed>/pulumi-import
├── @pulumi/aws@4.16.0
├── @pulumi/awsx@0.30.0
├── @pulumi/pulumi@3.10.3
└── @types/node@10.17.60
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Troubleshooting VM Import/Export - AWS Documentation
When you import a VM using the ec2-import-instance command, the import task might stop before its completed, and then fail. To investigate what...
Read more >Unable to import my vmdk to EC2 [duplicate] - Super User
The error message suggests you are not in the correct region. According to the AWS documentation you need to specify a zone.
Read more >Unable to import module 'index': Error on Amazon Linux EC2 ...
Hi i am seeing the aforementioned error error while running the command "sam local invoke "HelloWorld" -e input/events.json " from the directory where...
Read more >Unable to import EC2 instance with pulumi import command
I am running an EC2 instance on aws which I need to import to pulumi by running the following command pulumi import -f...
Read more >How do I resolve the "Unable to import module ... - YouTube
... Knowledge Center article with this video: https:// aws.amazon.com/premiumsupport/knowledge-center/lambda- import -module-error-python/0...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Unless I am mistaken, the root cause is this:
https://github.com/pulumi/pulumi/blob/da2bd2ab043f2588b3a136846da1b97505326f25/pkg/resource/deploy/step.go#L935-L938
This limits the propagation of read properties to inputs based on
IsRequired
. There are plenty of non-required properties that are valid inputs. In this specific case, for example, I assume we can’t tell from the schema alone that the AtLeastOne constraints exist which are dynamically validated.I tried removing that line (since the iteration is already limited to input properties only), but that just yielded more problems:
I think we may need to deeply strip out “empty” values like maps, arrays, etc, but it’s even more complicated because they contain
__defaults
properties and I actually don’t know why computed-only properties likeroot_block_device
are in the input property set from the schema in the first place.Import functionality has been significantly refactored in #8922 to substantially reduce the number of failures during
pulumi import
and make the generated code more truthful and complete. We haven’t tested this exact issue, but we believe it’s addressed by the refactoring.I’ll go ahead and close the issue - feel free if you still get issues with it after upgrading to the Pulumi CLI version 3.26.1 or above.
Read more about the changes in Easier IaC adoption with improved
pulumi import
experience.