Amit
Amit

Reputation: 6304

Node AWS SDK start an instance

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

Answers (1)

Ashan
Ashan

Reputation: 19758

You can write the logic to check the EC2 instance status using describeInstanceStatus method which will return the instance states (InstanceState.Name)

  • pending
  • running
  • shutting-down
  • terminated
  • stopping
  • stopped

Based on the current state (running or stopped) you can toggle the instance state using either of the following method.

Upvotes: 1

Related Questions