What is @aws-sdk/client-rds?
The @aws-sdk/client-rds package is part of the AWS SDK for JavaScript. It allows developers to interact with Amazon Relational Database Service (RDS) programmatically. This includes creating, managing, and deleting RDS instances, managing databases, and handling backups and snapshots.
What are @aws-sdk/client-rds's main functionalities?
CreateDBInstance
This feature allows you to create a new RDS instance. The code sample demonstrates how to create a MySQL database instance with specific parameters such as instance identifier, storage, instance class, engine type, and master username and password.
const { RDSClient, CreateDBInstanceCommand } = require('@aws-sdk/client-rds');
const client = new RDSClient({ region: 'us-west-2' });
const params = {
DBInstanceIdentifier: 'mydbinstance',
AllocatedStorage: 20,
DBInstanceClass: 'db.t2.micro',
Engine: 'mysql',
MasterUsername: 'admin',
MasterUserPassword: 'password123'
};
const run = async () => {
try {
const data = await client.send(new CreateDBInstanceCommand(params));
console.log('DB Instance Created', data);
} catch (err) {
console.error(err);
}
};
run();
DescribeDBInstances
This feature allows you to retrieve information about your RDS instances. The code sample demonstrates how to describe all RDS instances in a specific region.
const { RDSClient, DescribeDBInstancesCommand } = require('@aws-sdk/client-rds');
const client = new RDSClient({ region: 'us-west-2' });
const run = async () => {
try {
const data = await client.send(new DescribeDBInstancesCommand({}));
console.log('DB Instances', data);
} catch (err) {
console.error(err);
}
};
run();
DeleteDBInstance
This feature allows you to delete an existing RDS instance. The code sample demonstrates how to delete a database instance by specifying the instance identifier and skipping the final snapshot.
const { RDSClient, DeleteDBInstanceCommand } = require('@aws-sdk/client-rds');
const client = new RDSClient({ region: 'us-west-2' });
const params = {
DBInstanceIdentifier: 'mydbinstance',
SkipFinalSnapshot: true
};
const run = async () => {
try {
const data = await client.send(new DeleteDBInstanceCommand(params));
console.log('DB Instance Deleted', data);
} catch (err) {
console.error(err);
}
};
run();
Other packages similar to @aws-sdk/client-rds
pg
The 'pg' package is a PostgreSQL client for Node.js. It allows you to interact with PostgreSQL databases, including executing SQL queries and managing database connections. Unlike @aws-sdk/client-rds, which is specific to AWS RDS, 'pg' is specific to PostgreSQL and does not provide management features for other types of databases or cloud services.
mysql
The 'mysql' package is a MySQL client for Node.js. It allows you to interact with MySQL databases, including executing SQL queries and managing database connections. Similar to 'pg', it is specific to MySQL and does not provide the broader management capabilities for RDS instances that @aws-sdk/client-rds offers.
sequelize
Sequelize is a promise-based Node.js ORM for various SQL databases, including MySQL, PostgreSQL, SQLite, and MSSQL. It provides a higher-level abstraction for database operations, including model definitions and associations. While it can be used with RDS databases, it does not provide the direct management capabilities for RDS instances that @aws-sdk/client-rds does.