0.1.2 • Published 3 years ago

aws-rds-data-api-seeder v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

AWS RDS Data-API Seeder

Installation

npm install --save-dev aws-rds-data-api-seeder

Usage

Standard

> npx ./scripts/seeds/users.js \
  --database my_database \
  --resource-arn arn:aws:rds:us-east-2:123456789012:cluster:my-aurora-cluster-1 \
  --secret-arn arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c

Alternate Profile

In order to use a profile other than the default one configured in your .aws directory you need to specify the name via AWS_PROFILE environment variable.

Additionally you will need to specify AWS_SDK_LOAD_CONFIG=1 (see AWS docs) to be able to load config from the .aws/config file.

> AWS_SDK_LOAD_CONFIG=1 AWS_PROFILE=my-profile-name npx ./scripts/seeds/users.js \
  --database my_database \
  --resource-arn arn:aws:rds:us-east-2:123456789012:cluster:my-aurora-cluster-1 \
  --secret-arn arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c

TypeScript

> npx ts-node ./scripts/seeds/users.ts \
  --database my_database \
  --resource-arn arn:aws:rds:us-east-2:123456789012:cluster:my-aurora-cluster-1 \
  --secret-arn arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c

Help

> npx ./scripts/seeds/users.js --help
Usage: seeder [options]

Options:
  -d, --database <database name>     The name of the database to connect to. Can also by set by the SEED_DATABASE environment variable.
  -q, --schema <database name>       The name of the schema to use. Can also be set by the SEED_SCHEMA environment variable. (default: "public")
  -r, --resource-arn <resource arn>  The resource ARN of the database cluster. Can also be set by the SEED_RESOURCE_ARN environment variable.
  -s, --secret-arn <secret arn>      The secret ARN to give for the seed credentials. Can also be set by the SEED_SECRET_ARN environment variable.
  --region <region>                  The AWS region the cluster is in. Can also by set by the AWS_REGION environment variable.
  -n, --dry-run                      Rolls back the transaction instead of committing. Useful for testing operations.
  -vvv, --verbose                    Enable verbose logging.
  -h, --help                         display help for command