We are getting `Target 'urn:XXX' could not be foun...
# general
q
We are getting
Target 'urn:XXX' could not be found in the stack
error when trying to apply resource. However, we can see the resource with the urn both in the state and AWS console. What could that mean and what could be the fix?
b
are you on the right stack?
q
yes i am
it also shows resource to be deleted in the plan
b
Can you share the diff?
q
Copy code
Previewing update (single-region-test):
     Type                              Name                                    Plan       Info
     pulumi:pulumi:Stack               single-region-stack-single-region-test             3 errors
 -   ├─ aws:ec2:RouteTableAssociation  eu-west-1c-public                       delete     
 -   ├─ aws:ec2:Route                  eu-west-1c-public                       delete     
 -   └─ aws:ec2:Subnet                 eu-west-1c-public                       delete     
 
Diagnostics:
  pulumi:pulumi:Stack (single-region-stack-single-region-test):
    error: Target 'urn:pulumi:single-region-test::single-region-stack::dycloud:index:Ec2Vpc$dycloud:index:Subnet$aws:ec2/routeTableAssociation:RouteTableAssociation' could not be found in the stack.
    error: Target 'urn:pulumi:single-region-test::single-region-stack::dycloud:index:Ec2Vpc$dycloud:index:Subnet$aws:ec2/subnet:Subnet::eu-west-1c-public' could not be found in the stack.
    error: Target 'urn:pulumi:single-region-test::single-region-stack::dycloud:index:Ec2Vpc$dycloud:index:Subnet$aws:ec2/route:Route::eu-west-1c-public' could not be found in the stack.
b
Can you run pulumi refresh ?
q
didn't fix it
b
I've honestly never seen this error, very surprised the stack is in this state: • can you share the code you're using to define your program • can you shack the output of
pulumi stack export
(in a github gist if it's long)
q
it looks like this is caused if you run pulumi up targeting a custom resource and it has other resources nested under it
then it loses references somehow
we can't publish state, sorry 🙂