title: How to start and stop EC2 instance using Lambda
body: <p>I am trying to start and stop an EC2 windows instance using lambda, i am using Node.js 8.10 to write the start and stop script.When i am testing the script the script is executed successfully but the EC2 instance is not effected.I am giving the instance details and script below  </p>
  
  <pre><code>const AWS = require('aws-sdk');
  
  exports.handler = async (event) =&gt; {
  
  const ec2 = new AWS.EC2({ region: event.instanceRegion });
   ec2.stopInstances({ InstanceIds: [event.instanceId] }).promise()
      .then(() =&gt; callback(null, `Successfully stopped ${event.instanceId}`))
      .catch(err =&gt; callback(err));
  };
  </code></pre>
  
  <p>The script executed successfully </p>
  
  <p><a href="https://i.stack.imgur.com/Y20jm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y20jm.png" alt="enter image description here"></a></p>
  
  <p>Below is the instance details 
  <a href="https://i.stack.imgur.com/93yHa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/93yHa.png" alt="enter image description here"></a></p>
  
  <p>This is stop script but this is not able to stop the instance , please help me i am new to aws . Thanks in advance</p>