Is there a way to programmatically delete a resour...
# general
r
Is there a way to programmatically delete a resource on the stack? For example, I want to spin up and EC2 instance, do some computation and delete this instance when I'm done.
l
@rhythmic-whale-48997 I guess the scenario you mentioned is better suited for a service like AWS Batch. https://docs.aws.amazon.com/batch/latest/userguide/what-is-batch.html https://www.pulumi.com/registry/packages/aws/api-docs/batch/
r
No, this is a special kind of workload that requires me to add EC2 to the EKS cluster via NodeGroup. We are somewhat special 😅 in that regards.
But this AWS Batch looks good, I will not disregard it 🙂
l
@rhythmic-whale-48997 is that special workload running containerized then, given you mention EKS?
r
Yup, and connecting to the Amazon MQ and also the computation can take from 1min to couple of hours
e
This isn’t supported today, but we have thought about the being able to mark a resources as transient just for the deployment, or even having an explicit delete method maybe. We don’t have an issue tracking this (it’s previously come up as part of cyclic work, see https://github.com/pulumi/pulumi/issues/3021) but feel free to raise an issue just for this. Might be more tractable by itself.
👀 1
👍 1
l
@rhythmic-whale-48997 the closest to simulating your needs is this: • create a custom
NodeGroup
which has default instance count set to
0
but is allowed to scale up and down. • schedule your workload as a K8s Job with special pod placement tactics so it can only end up on the special EC2 NodeGroup When the job is scheduled, EKS will first scale up with 1 instances to host your job, and after the job is run, you allow the NodeGroup to scale down again. Here is a link to an AWS workshop explaining this: https://www.eksworkshop.com/beginner/140_assigning_pods/
r
@limited-rainbow-51650 this is a good idea, I will take a look. Thank you for the help and support
🙏🏼 1