Trying to import infrastructure that we already de...
# general
m
Trying to import infrastructure that we already deployed prior to adopting pulumi and I am having trouble importing a few ec2's. Here is the command I am running that should generate the ts file to do the final import:
pulumi import aws:ec2/instance:Instance github-runner-1 <instance-id>
I am met with the error:
Copy code
Previewing import (dev)

View Live: <https://app.pulumi.com/lwooden/github-runners/dev/previews/d953777e-c02b-4d34-8718-8382479da9e1>

     Type                 Name                Plan       Info
 +   pulumi:pulumi:Stack  github-runners-dev  create     1 error
 =   └─ aws:ec2:Instance  github-runner-1     import     4 errors
 
Diagnostics:
  pulumi:pulumi:Stack (github-runners-dev):
    error: preview failed
 
  aws:ec2:Instance (github-runner-1):
    error: aws:ec2/instance:Instance resource 'github-runner-1' 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 'github-runner-1' has a problem: AtLeastOne: "ami": one of `ami,launch_template` must be specified. Examine values at 'Instance.Ami'.
    error: aws:ec2/instance:Instance resource 'github-runner-1' has a problem: AtLeastOne: "instance_type": one of `instance_type,launch_template` must be specified. Examine values at 'Instance.InstanceType'.
    error: Preview failed: one or more inputs failed to validate
Doing a describe instance via the aws cli clearly shows that all of the above fields (ami, instance_type, etc) exists for this resources so I am at a lost as to why pulumi is having issue picking them up 😞 Any pointers would be great. I've exhausted the documentation and have spent hours on this
l
Looks like the AWS API does not allow launch_template and either of the other two properties.
You need to remove whichever is not used.
Quite possibly the code-generating feature of import doesn't support the idea of exclusive-or properties.
The docs say that if you use a launch_template with an AMI, then you must not provide an AMI in the instance. Same for instance_type.
Hmm, actually these docs are pretty confusing. I can't tell if it's must or most not. Need more coffee... https://docs.aws.amazon.com/autoscaling/ec2/userguide/LaunchTemplates.html
m
This instance was not build from a launch_template at all. That's why I don't understand why pulumi thinks that it was
l
Remove the launch_template stuff then. It's causing the problems.
n
Hi @modern-belgium-42936, were you able to solve this problem?
m
Unfortunately not :( @numerous-pharmacist-73685
g
Hi @modern-belgium-42936, I’m seeing the same error for this command, and am unable to proceed. Have you had any success on this yet?