Reputation: 6304
Using the node aws-sdk, I check the status of an instance, and want to let a user start it if it is dead, or kill it if it is alive.
I found that there is a method called runinstances
but it seems like it creates new instances, and I want to revive a live one.
Is there a way using the node sdk to start/kill an instance?
Upvotes: 0
Views: 53
Reputation: 19758
You can write the logic to check the EC2 instance status using describeInstanceStatus method which will return the instance states (InstanceState.Name
)
Based on the current state (running or stopped) you can toggle the instance state using either of the following method.
Upvotes: 1