i am creating multiple eks cluster in single stack...
# general
t
i am creating multiple eks cluster in single stack using automation api in golang, Now i would like to delete one of eks cluster using automation api , could anyone pls point me to some example to delete resource in stack
b
don't think you can delete one single resource inside a stack, this is for IAC usage, if you just want to randomly play around resources, you should do it manually
t
Thanks @brash-quill-35776 for reply to delete resource manually , one method i am using URN as per following code
Copy code
ursrole := []string{"urn:pulumi:stack1::project1::aws:eks/cluster:Cluster::eks-cluster-1"}
	// destroy the stack
	//we'll write all of the logs to stdout so we can watch requests get processed
	_, err = s.Destroy(ctx, optdestroy.Target(ursrole))
	if err != nil {
		fmt.Println(err.Error())
	}
I am getting following error , is this right method to delete resource manually.?
Copy code
failed to destroy stack: exit status 1
code: 1
stdout: 
stderr: Error: unknown flag: --target urn:pulumi:stack1::project1::aws:eks/cluster:Cluster::eks-cluster-1
Usage:
Also i would like to confirm if i am providing right format to delete resources
Copy code
ursrole := []string{"urn:pulumi:stack1::project1::aws:eks/cluster:Cluster::eks-cluster-1"}
b
it depends, please check AWS doc. Pulumi is mean to create resources in IAC fashion so you can programatically create and destroy environment in reproducible way, rather than manually doing so. if you are sure that 1 resource is no longer require, you should remove it from your pulumi and update the stack again.
t
Thanks @brash-quill-35776 this were i am struggling how to remove resource programtically using automation api the only option i found is to destroy stack and resources.
Copy code
// destroy the stack
	//we'll write all of the logs to stdout so we can watch requests get processed
	_, err = s.Destroy(ctx, optdestroy.ProgressStreams(os.Stdout))
	if err != nil {
		fmt.Println(err.Error())
	}
b
simply remove it from your code and
pulumi up
should be all good
t
do you mean removing the resource from stack file and then pulumi up?
b
ya
which from your code
t
What do you mean by
which from your code
b
literally remove it from your code
like you created 3 resources, and now you remove 1 of them , then run
pulumi up
t
i am using this example
<https://github.com/pulumi/examples/blob/master/aws-go-eks/main.go>
to create multiple eks cluster using rest api which mean the same code can be used to create multile cluster in single stack, what i am not understand what code need to be remove to destroy specific eks clsuter. How pulumi will understand which specific cluster resource need deleting if i remove form a specific section of my code. Also the values for the resources are dynamically provided during cluster creation.
b
please try it
d
@thousands-planet-78612 Did you ever found a solution to that
unknown flag: --target
error? I am getting the same when using the Go automation API but the URN is definitely valid.
In case anyone run into the same issue: https://github.com/pulumi/pulumi/pull/8109