Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-sdk/client-ec2

Package Overview
Dependencies
Maintainers
5
Versions
507
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/client-ec2

AWS SDK for JavaScript Ec2 Client for Node.js, Browser and React Native

  • 3.712.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
614K
increased by0.94%
Maintainers
5
Weekly downloads
 
Created

What is @aws-sdk/client-ec2?

@aws-sdk/client-ec2 is a part of the AWS SDK for JavaScript, which allows developers to interact with Amazon EC2 (Elastic Compute Cloud) services. This package provides a comprehensive set of functionalities to manage EC2 instances, security groups, key pairs, and other related resources programmatically.

What are @aws-sdk/client-ec2's main functionalities?

Launch an EC2 Instance

This code sample demonstrates how to launch a new EC2 instance using the @aws-sdk/client-ec2 package. It specifies the AMI ID, instance type, and the number of instances to launch.

const { EC2Client, RunInstancesCommand } = require('@aws-sdk/client-ec2');

const client = new EC2Client({ region: 'us-west-2' });

const run = async () => {
  const command = new RunInstancesCommand({
    ImageId: 'ami-0abcdef1234567890',
    InstanceType: 't2.micro',
    MinCount: 1,
    MaxCount: 1
  });
  const response = await client.send(command);
  console.log(response);
};

run();

Describe EC2 Instances

This code sample shows how to describe EC2 instances using the @aws-sdk/client-ec2 package. It retrieves information about all EC2 instances in the specified region.

const { EC2Client, DescribeInstancesCommand } = require('@aws-sdk/client-ec2');

const client = new EC2Client({ region: 'us-west-2' });

const describe = async () => {
  const command = new DescribeInstancesCommand({});
  const response = await client.send(command);
  console.log(response);
};

describe();

Terminate an EC2 Instance

This code sample demonstrates how to terminate an EC2 instance using the @aws-sdk/client-ec2 package. It specifies the instance ID of the EC2 instance to be terminated.

const { EC2Client, TerminateInstancesCommand } = require('@aws-sdk/client-ec2');

const client = new EC2Client({ region: 'us-west-2' });

const terminate = async () => {
  const command = new TerminateInstancesCommand({
    InstanceIds: ['i-0abcdef1234567890']
  });
  const response = await client.send(command);
  console.log(response);
};

terminate();

Create a Security Group

This code sample shows how to create a new security group using the @aws-sdk/client-ec2 package. It specifies the group name, description, and VPC ID.

const { EC2Client, CreateSecurityGroupCommand } = require('@aws-sdk/client-ec2');

const client = new EC2Client({ region: 'us-west-2' });

const createSecurityGroup = async () => {
  const command = new CreateSecurityGroupCommand({
    GroupName: 'my-security-group',
    Description: 'My security group',
    VpcId: 'vpc-0abcdef1234567890'
  });
  const response = await client.send(command);
  console.log(response);
};

createSecurityGroup();

Other packages similar to @aws-sdk/client-ec2

FAQs

Package last updated on 13 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc