New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@aws-sdk/client-ec2

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
a

@aws-sdk/client-ec2

@aws-sdk/client-ec2 client

1.0.0-gamma.9
98

Supply Chain Security

100

Vulnerability

79

Quality

99

Maintenance

100

License

Version published
Weekly downloads
822K
3.59%
Maintainers
5
Weekly downloads
 
Created
Issues
220

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 15 Sep 2020

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