@aws- sdk/rds- signer (帮助) (帮助)
说明
这个软件包提供与RDS互动的公用设施.
安装
npm install @aws-sdk/rds-signer
开始
导入
ES6 导入
import { Signer } from "@aws-sdk/rds-signer";
或者普通JS导入
const { Signer } = require("@aws-sdk/rds-signer");
生成 RDS IAM 认证的认证托肯
const signer = new Signer({
/**
* Required. The hostname of the database to connect to.
*/
hostname: "db.us-east-1.rds.amazonaws.com",
/**
* Required. The port number the database is listening on.
*/
port: 8000,
/**
* Required. The username to login as.
*/
username: "user1",
/**
* Optional. The AWS credentials to sign requests with. Uses the default credential provider chain if not specified.
*/
credentials: fromNodeCredentialProvider(),
/**
* Optional. The region the database is located in. Uses the region inferred from the runtime if omitted.
*/
region: "us-east-1",
/**
* Optional. The SHA256 hasher constructor to sign the request.
*/
sha256: HashCtor,
});
const token = await signer.getAuthToken();
// Use this token as the password for connecting to your RDS instance
欲了解更多详情和实例,请参见以下资源。 整个DB引擎的用法类似.