rds-aurora-bootstrapper 0.5.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +42 -42
- package/API.md +17 -0
- package/README.md +3 -2
- package/assets/funcs/bootstrap.lambda/index.js +393 -0
- package/lib/aurora-database-create-migrator.d.ts +3 -0
- package/lib/aurora-database-create-migrator.js +8 -4
- package/lib/aurora-database-create-owner.d.ts +8 -0
- package/lib/aurora-database-create-owner.js +13 -8
- package/lib/aurora-database-create-schema.d.ts +3 -0
- package/lib/aurora-database-create-schema.js +8 -4
- package/lib/aurora-database-create-user.d.ts +3 -0
- package/lib/aurora-database-create-user.js +8 -4
- package/lib/funcs/bootstrap-function.d.ts +15 -0
- package/lib/funcs/bootstrap-function.js +57 -0
- package/lib/funcs/bootstrap.lambda.d.ts +16 -0
- package/lib/funcs/bootstrap.lambda.js +63 -0
- package/lib/funcs/core/create-migrator.d.ts +20 -0
- package/lib/funcs/core/create-migrator.js +73 -0
- package/lib/funcs/core/create-owner.d.ts +18 -0
- package/lib/funcs/core/create-owner.js +55 -0
- package/lib/funcs/core/create-schema.d.ts +15 -0
- package/lib/funcs/core/create-schema.js +58 -0
- package/lib/funcs/core/create-user.d.ts +20 -0
- package/lib/funcs/core/create-user.js +80 -0
- package/lib/funcs/core/load-login-credentials.d.ts +23 -0
- package/lib/funcs/core/load-login-credentials.js +32 -0
- package/lib/funcs/core/rds-data-transaction.d.ts +15 -0
- package/lib/funcs/core/rds-data-transaction.js +39 -0
- package/lib/funcs/core/read-rds-data-target.d.ts +20 -0
- package/lib/funcs/core/read-rds-data-target.js +21 -0
- package/lib/funcs/core/read-string-property.d.ts +5 -3
- package/lib/funcs/core/read-string-property.js +1 -1
- package/lib/funcs/core/role-exists.d.ts +12 -0
- package/lib/funcs/core/role-exists.js +24 -0
- package/lib/settings/consts.d.ts +10 -0
- package/lib/settings/consts.js +12 -2
- package/package.json +12 -10
- package/assets/funcs/create-migrator.lambda/index.js +0 -207
- package/assets/funcs/create-migrator.lambda/index.js.map +0 -7
- package/assets/funcs/create-owner.lambda/index.js +0 -153
- package/assets/funcs/create-owner.lambda/index.js.map +0 -7
- package/assets/funcs/create-schema.lambda/index.js +0 -150
- package/assets/funcs/create-schema.lambda/index.js.map +0 -7
- package/assets/funcs/create-user.lambda/index.js +0 -212
- package/assets/funcs/create-user.lambda/index.js.map +0 -7
- package/lib/funcs/create-migrator-function.d.ts +0 -13
- package/lib/funcs/create-migrator-function.js +0 -56
- package/lib/funcs/create-migrator.lambda.d.ts +0 -25
- package/lib/funcs/create-migrator.lambda.js +0 -139
- package/lib/funcs/create-owner-function.d.ts +0 -13
- package/lib/funcs/create-owner-function.js +0 -56
- package/lib/funcs/create-owner.lambda.d.ts +0 -21
- package/lib/funcs/create-owner.lambda.js +0 -107
- package/lib/funcs/create-schema-function.d.ts +0 -13
- package/lib/funcs/create-schema-function.js +0 -56
- package/lib/funcs/create-schema.lambda.d.ts +0 -21
- package/lib/funcs/create-schema.lambda.js +0 -113
- package/lib/funcs/create-user-function.d.ts +0 -13
- package/lib/funcs/create-user-function.js +0 -56
- package/lib/funcs/create-user.lambda.d.ts +0 -25
- package/lib/funcs/create-user.lambda.js +0 -145
package/.jsii
CHANGED
|
@@ -8456,7 +8456,7 @@
|
|
|
8456
8456
|
},
|
|
8457
8457
|
"name": "rds-aurora-bootstrapper",
|
|
8458
8458
|
"readme": {
|
|
8459
|
-
"markdown": "# RDS Aurora Bootstrapper (CDK v2)\n\n[](https://www.npmjs.com/package/rds-aurora-bootstrapper)\n[](https://www.npmjs.com/package/rds-aurora-bootstrapper)\n[](https://www.npmjs.com/package/rds-aurora-bootstrapper)\n[](https://github.com/gammarers-aws-cdk-constructs/rds-aurora-bootstrapper/actions/workflows/build.yml)\n\n[](https://constructs.dev/packages/rds-aurora-bootstrapper)\n\nAWS CDK constructs for bootstrapping Aurora PostgreSQL databases via the RDS Data API.\n\n## Features\n\n- **`AuroraDatabaseCreateOwner`** — creates a `NOLOGIN NOINHERIT` owner role and grants it to the master user\n- **`AuroraDatabaseCreateSchema`** — creates a schema, assigns ownership to an existing owner role, and drops the `public` schema with `CASCADE` when `PublicSchema.DROP` is set\n- **`AuroraDatabaseCreateUser`** — creates a `LOGIN` application user from a Secrets Manager credential secret, grants `CONNECT` / schema `USAGE` / table DML, and sets default privileges for the owner role\n- **`AuroraDatabaseCreateMigrator`** — creates a `LOGIN` migrator user from a Secrets Manager credential secret, grants `CONNECT`, grants membership in the owner role, and sets `search_path` to the target schema\n- Idempotent owner, user, and migrator role creation — skips creation when the role already exists\n- Validates PostgreSQL identifiers at synthesis time (`ownerUsername`, `schemaName`)\n- Resolves the master username from the credentials secret through a CloudFormation dynamic reference\n\n## How it works\n\nAdd the constructs to a stack in order: owner role, schema, migrator user, then application user. On deploy,
|
|
8459
|
+
"markdown": "# RDS Aurora Bootstrapper (CDK v2)\n\n[](https://www.npmjs.com/package/rds-aurora-bootstrapper)\n[](https://www.npmjs.com/package/rds-aurora-bootstrapper)\n[](https://www.npmjs.com/package/rds-aurora-bootstrapper)\n[](https://github.com/gammarers-aws-cdk-constructs/rds-aurora-bootstrapper/actions/workflows/build.yml)\n\n[](https://constructs.dev/packages/rds-aurora-bootstrapper)\n\nAWS CDK constructs for bootstrapping Aurora PostgreSQL databases via the RDS Data API.\n\n## Features\n\n- **`AuroraDatabaseCreateOwner`** — creates a `NOLOGIN NOINHERIT` owner role and grants it to the master user\n- **`AuroraDatabaseCreateSchema`** — creates a schema, assigns ownership to an existing owner role, and drops the `public` schema with `CASCADE` when `PublicSchema.DROP` is set\n- **`AuroraDatabaseCreateUser`** — creates a `LOGIN` application user from a Secrets Manager credential secret, grants `CONNECT` / schema `USAGE` / table DML, and sets default privileges for the owner role\n- **`AuroraDatabaseCreateMigrator`** — creates a `LOGIN` migrator user from a Secrets Manager credential secret, grants `CONNECT`, grants membership in the owner role, and sets `search_path` to the target schema\n- Idempotent owner, user, and migrator role creation — skips creation when the role already exists\n- Updating or deleting a construct leaves the role and schema in place\n- Validates PostgreSQL identifiers at synthesis time (`ownerUsername`, `schemaName`)\n- Resolves the master username from the credentials secret through a CloudFormation dynamic reference\n\n## How it works\n\nAdd the constructs to a stack in order: owner role, schema, migrator user, then application user. On deploy, the constructs share one Lambda function that calls the Aurora RDS Data API with the master credentials.\n\nThe owner construct creates a `NOLOGIN NOINHERIT` role and grants it to the master user. The schema construct creates the schema, assigns that owner, and either leaves or drops the `public` schema. The migrator construct creates a `LOGIN` role that belongs to the owner and uses the schema as `search_path`. The application user construct creates a `LOGIN` role with connect, schema usage, and table DML privileges. When a role already exists, creation is skipped. Updating or deleting the custom resource does not drop the role or schema.\n\n## Installation\n\n### npm\n\n```bash\nnpm install rds-aurora-bootstrapper\n```\n\n### yarn\n\n```bash\nyarn add rds-aurora-bootstrapper\n```\n\n### pnpm\n\n```bash\npnpm add rds-aurora-bootstrapper\n```\n\n## Usage\n\nProvision resources in order: owner role → schema → migrator user → application user.\n\n```typescript\nimport { Stack } from 'aws-cdk-lib';\nimport { Vpc } from 'aws-cdk-lib/aws-ec2';\nimport {\n AuroraPostgresEngineVersion,\n ClusterInstance,\n DatabaseCluster,\n DatabaseClusterEngine,\n} from 'aws-cdk-lib/aws-rds';\nimport { Secret } from 'aws-cdk-lib/aws-secretsmanager';\nimport { Construct } from 'constructs';\nimport {\n AuroraDatabaseCreateOwner,\n AuroraDatabaseCreateSchema,\n AuroraDatabaseCreateMigrator,\n AuroraDatabaseCreateUser,\n PublicSchema,\n} from 'rds-aurora-bootstrapper';\n\nexport class MyStack extends Stack {\n constructor(scope: Construct, id: string) {\n super(scope, id);\n\n const vpc = new Vpc(this, 'Vpc', { maxAzs: 2 });\n const cluster = new DatabaseCluster(this, 'Cluster', {\n engine: DatabaseClusterEngine.auroraPostgres({\n version: AuroraPostgresEngineVersion.VER_17_6,\n }),\n vpc,\n writer: ClusterInstance.provisioned('writer'),\n });\n const masterUserSecret = new Secret(this, 'MasterUserSecret');\n const migratorUserSecret = new Secret(this, 'MigratorUserSecret', {\n generateSecretString: {\n secretStringTemplate: JSON.stringify({ username: 'app_migrator' }),\n generateStringKey: 'password',\n excludePunctuation: true,\n },\n });\n const appUserSecret = new Secret(this, 'AppUserSecret', {\n generateSecretString: {\n secretStringTemplate: JSON.stringify({ username: 'app_user' }),\n generateStringKey: 'password',\n excludePunctuation: true,\n },\n });\n\n const createOwner = new AuroraDatabaseCreateOwner(this, 'CreateOwner', {\n dbMasterUserCredentials: masterUserSecret,\n dbCluster: cluster,\n dbName: 'appdb',\n ownerUsername: 'app_owner',\n });\n\n const createSchema = new AuroraDatabaseCreateSchema(this, 'CreateSchema', {\n dbMasterUserCredentials: masterUserSecret,\n dbCluster: cluster,\n dbName: 'appdb',\n ownerUsername: 'app_owner',\n schemaName: 'app_schema',\n publicSchema: PublicSchema.DROP,\n });\n createSchema.node.addDependency(createOwner);\n\n const createMigrator = new AuroraDatabaseCreateMigrator(this, 'CreateMigrator', {\n dbMasterUserCredentials: masterUserSecret,\n migratorUserCredentials: migratorUserSecret,\n dbCluster: cluster,\n dbName: 'appdb',\n ownerUsername: 'app_owner',\n schemaName: 'app_schema',\n });\n createMigrator.node.addDependency(createSchema);\n\n const createUser = new AuroraDatabaseCreateUser(this, 'CreateUser', {\n dbMasterUserCredentials: masterUserSecret,\n targetUserCredentials: appUserSecret,\n dbCluster: cluster,\n dbName: 'appdb',\n ownerUsername: 'app_owner',\n schemaName: 'app_schema',\n });\n createUser.node.addDependency(createSchema);\n }\n}\n```\n\nSet `publicSchema` to `PublicSchema.KEEP` to leave the `public` schema in place.\n\n## Options\n\n### `AuroraDatabaseCreateOwnerProps`\n\n| Property | Type | Description |\n| --- | --- | --- |\n| `dbMasterUserCredentials` | `Secret` | Secrets Manager secret with Aurora master credentials. The `username` field is passed to the custom resource via a dynamic reference. |\n| `dbCluster` | `DatabaseCluster` | Aurora database cluster where the owner role is created. |\n| `dbName` | `string` | PostgreSQL database name targeted by the custom resource. |\n| `ownerUsername` | `string` | Username of the owner role to create (`NOLOGIN`, `NOINHERIT`). Must match `^[a-zA-Z_][a-zA-Z0-9_-]*$`. |\n\n### `AuroraDatabaseCreateSchemaProps`\n\n| Property | Type | Description |\n| --- | --- | --- |\n| `dbMasterUserCredentials` | `Secret` | Secrets Manager secret with Aurora master credentials. The `username` field is passed to the custom resource via a dynamic reference. |\n| `dbCluster` | `DatabaseCluster` | Aurora database cluster where the schema is created. |\n| `dbName` | `string` | PostgreSQL database name targeted by the custom resource. |\n| `ownerUsername` | `string` | Username of the existing owner role that will own the new schema. Must match `^[a-zA-Z_][a-zA-Z0-9_-]*$`. |\n| `schemaName` | `string` | Name of the PostgreSQL schema to create. Must match `^[a-zA-Z_][a-zA-Z0-9_-]*$`. |\n| `publicSchema` | `PublicSchema` | `KEEP` leaves the `public` schema in place. `DROP` drops it with `CASCADE` after creating the target schema. |\n\n### `AuroraDatabaseCreateMigratorProps`\n\n| Property | Type | Description |\n| --- | --- | --- |\n| `dbMasterUserCredentials` | `Secret` | Secrets Manager secret with Aurora master credentials. The `username` field is passed to the custom resource via a dynamic reference. |\n| `migratorUserCredentials` | `Secret` | Secrets Manager secret with the migrator user credentials (`username` and `password`). Used at runtime to create the `LOGIN` role. |\n| `dbCluster` | `DatabaseCluster` | Aurora database cluster where the migrator role is created. |\n| `dbName` | `string` | PostgreSQL database name targeted by the custom resource. |\n| `ownerUsername` | `string` | Username of the existing owner role granted to the migrator. Must match `^[a-zA-Z_][a-zA-Z0-9_-]*$`. |\n| `schemaName` | `string` | Name of the PostgreSQL schema used as the migrator's `search_path`. Must match `^[a-zA-Z_][a-zA-Z0-9_-]*$`. |\n\n### `AuroraDatabaseCreateUserProps`\n\n| Property | Type | Description |\n| --- | --- | --- |\n| `dbMasterUserCredentials` | `Secret` | Secrets Manager secret with Aurora master credentials. The `username` field is passed to the custom resource via a dynamic reference. |\n| `targetUserCredentials` | `Secret` | Secrets Manager secret with the application user credentials (`username` and `password`). Used at runtime to create the `LOGIN` role. |\n| `dbCluster` | `DatabaseCluster` | Aurora database cluster where the user role is created. |\n| `dbName` | `string` | PostgreSQL database name targeted by the custom resource. |\n| `ownerUsername` | `string` | Username of the existing owner role used for default privileges. Must match `^[a-zA-Z_][a-zA-Z0-9_-]*$`. |\n| `schemaName` | `string` | Name of the PostgreSQL schema the new user is granted access to. Must match `^[a-zA-Z_][a-zA-Z0-9_-]*$`. |\n\n## API\n\nSee [API.md](API.md).\n\n## Requirements\n\n- Node.js `>= 20.0.0`\n- `aws-cdk-lib` `^2.232.0`\n- `constructs` `^10.5.1`\n- Aurora PostgreSQL cluster with the [RDS Data API](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) enabled\n- Secrets Manager secrets containing `username` and `password` fields (master credentials, and application / migrator user credentials for `AuroraDatabaseCreateUser` / `AuroraDatabaseCreateMigrator`)\n\n## License\n\nThis project is licensed under the Apache-2.0 License.\n"
|
|
8460
8460
|
},
|
|
8461
8461
|
"repository": {
|
|
8462
8462
|
"type": "git",
|
|
@@ -8473,7 +8473,7 @@
|
|
|
8473
8473
|
"assembly": "rds-aurora-bootstrapper",
|
|
8474
8474
|
"base": "constructs.Construct",
|
|
8475
8475
|
"docs": {
|
|
8476
|
-
"remarks": "On Create, the handler creates a `LOGIN` role from\n{@link AuroraDatabaseCreateMigratorProps.migratorUserCredentials} when the\nrole is missing, grants `CONNECT` on the database, grants membership in\n{@link AuroraDatabaseCreateMigratorProps.ownerUsername}, and sets\n`search_path` to {@link AuroraDatabaseCreateMigratorProps.schemaName}. Role\ncreation is idempotent when the username already exists.\n\nThe master username is derived from the `username` field of\n{@link AuroraDatabaseCreateMigratorProps.dbMasterUserCredentials} through a\nSecrets Manager dynamic reference; callers do not pass it explicitly.\n\nEnsure {@link AuroraDatabaseCreateMigratorProps.ownerUsername} and\n{@link AuroraDatabaseCreateMigratorProps.schemaName} already exist (for\nexample via {@link AuroraDatabaseCreateOwner } and\n{@link AuroraDatabaseCreateSchema }) before this resource runs.",
|
|
8476
|
+
"remarks": "On Create, the handler creates a `LOGIN` role from\n{@link AuroraDatabaseCreateMigratorProps.migratorUserCredentials} when the\nrole is missing, grants `CONNECT` on the database, grants membership in\n{@link AuroraDatabaseCreateMigratorProps.ownerUsername}, and sets\n`search_path` to {@link AuroraDatabaseCreateMigratorProps.schemaName}. Role\ncreation is idempotent when the username already exists.\n\nThe master username is derived from the `username` field of\n{@link AuroraDatabaseCreateMigratorProps.dbMasterUserCredentials} through a\nSecrets Manager dynamic reference; callers do not pass it explicitly.\n\nEnsure {@link AuroraDatabaseCreateMigratorProps.ownerUsername} and\n{@link AuroraDatabaseCreateMigratorProps.schemaName} already exist (for\nexample via {@link AuroraDatabaseCreateOwner } and\n{@link AuroraDatabaseCreateSchema }) before this resource runs.\n\nThe handler is a singleton Lambda shared with the other bootstrap constructs\nin the same stack.",
|
|
8477
8477
|
"stability": "stable",
|
|
8478
8478
|
"summary": "CDK construct that provisions a PostgreSQL migrator user on an Aurora cluster using a custom resource backed by the RDS Data API."
|
|
8479
8479
|
},
|
|
@@ -8488,7 +8488,7 @@
|
|
|
8488
8488
|
},
|
|
8489
8489
|
"locationInModule": {
|
|
8490
8490
|
"filename": "src/aurora-database-create-migrator.ts",
|
|
8491
|
-
"line":
|
|
8491
|
+
"line": 101
|
|
8492
8492
|
},
|
|
8493
8493
|
"parameters": [
|
|
8494
8494
|
{
|
|
@@ -8523,7 +8523,7 @@
|
|
|
8523
8523
|
"kind": "class",
|
|
8524
8524
|
"locationInModule": {
|
|
8525
8525
|
"filename": "src/aurora-database-create-migrator.ts",
|
|
8526
|
-
"line":
|
|
8526
|
+
"line": 92
|
|
8527
8527
|
},
|
|
8528
8528
|
"name": "AuroraDatabaseCreateMigrator",
|
|
8529
8529
|
"symbolId": "src/aurora-database-create-migrator:AuroraDatabaseCreateMigrator"
|
|
@@ -8539,7 +8539,7 @@
|
|
|
8539
8539
|
"kind": "interface",
|
|
8540
8540
|
"locationInModule": {
|
|
8541
8541
|
"filename": "src/aurora-database-create-migrator.ts",
|
|
8542
|
-
"line":
|
|
8542
|
+
"line": 42
|
|
8543
8543
|
},
|
|
8544
8544
|
"name": "AuroraDatabaseCreateMigratorProps",
|
|
8545
8545
|
"properties": [
|
|
@@ -8552,7 +8552,7 @@
|
|
|
8552
8552
|
"immutable": true,
|
|
8553
8553
|
"locationInModule": {
|
|
8554
8554
|
"filename": "src/aurora-database-create-migrator.ts",
|
|
8555
|
-
"line":
|
|
8555
|
+
"line": 54
|
|
8556
8556
|
},
|
|
8557
8557
|
"name": "dbCluster",
|
|
8558
8558
|
"type": {
|
|
@@ -8569,7 +8569,7 @@
|
|
|
8569
8569
|
"immutable": true,
|
|
8570
8570
|
"locationInModule": {
|
|
8571
8571
|
"filename": "src/aurora-database-create-migrator.ts",
|
|
8572
|
-
"line":
|
|
8572
|
+
"line": 47
|
|
8573
8573
|
},
|
|
8574
8574
|
"name": "dbMasterUserCredentials",
|
|
8575
8575
|
"type": {
|
|
@@ -8585,7 +8585,7 @@
|
|
|
8585
8585
|
"immutable": true,
|
|
8586
8586
|
"locationInModule": {
|
|
8587
8587
|
"filename": "src/aurora-database-create-migrator.ts",
|
|
8588
|
-
"line":
|
|
8588
|
+
"line": 56
|
|
8589
8589
|
},
|
|
8590
8590
|
"name": "dbName",
|
|
8591
8591
|
"type": {
|
|
@@ -8602,7 +8602,7 @@
|
|
|
8602
8602
|
"immutable": true,
|
|
8603
8603
|
"locationInModule": {
|
|
8604
8604
|
"filename": "src/aurora-database-create-migrator.ts",
|
|
8605
|
-
"line":
|
|
8605
|
+
"line": 52
|
|
8606
8606
|
},
|
|
8607
8607
|
"name": "migratorUserCredentials",
|
|
8608
8608
|
"type": {
|
|
@@ -8619,7 +8619,7 @@
|
|
|
8619
8619
|
"immutable": true,
|
|
8620
8620
|
"locationInModule": {
|
|
8621
8621
|
"filename": "src/aurora-database-create-migrator.ts",
|
|
8622
|
-
"line":
|
|
8622
|
+
"line": 61
|
|
8623
8623
|
},
|
|
8624
8624
|
"name": "ownerUsername",
|
|
8625
8625
|
"type": {
|
|
@@ -8636,7 +8636,7 @@
|
|
|
8636
8636
|
"immutable": true,
|
|
8637
8637
|
"locationInModule": {
|
|
8638
8638
|
"filename": "src/aurora-database-create-migrator.ts",
|
|
8639
|
-
"line":
|
|
8639
|
+
"line": 66
|
|
8640
8640
|
},
|
|
8641
8641
|
"name": "schemaName",
|
|
8642
8642
|
"type": {
|
|
@@ -8650,7 +8650,7 @@
|
|
|
8650
8650
|
"assembly": "rds-aurora-bootstrapper",
|
|
8651
8651
|
"base": "constructs.Construct",
|
|
8652
8652
|
"docs": {
|
|
8653
|
-
"remarks": "
|
|
8653
|
+
"remarks": "On Create, the handler creates a `NOLOGIN NOINHERIT` role when\n{@link AuroraDatabaseCreateOwnerProps.ownerUsername} is missing, and grants\nthat role to the master user. Role creation is idempotent when the username\nalready exists.\n\nThe master username is derived from the `username` field of\n{@link AuroraDatabaseCreateOwnerProps.dbMasterUserCredentials} through a\nSecrets Manager dynamic reference; callers do not pass it explicitly.\n\nThe handler is a singleton Lambda shared with the other bootstrap constructs\nin the same stack.",
|
|
8654
8654
|
"stability": "stable",
|
|
8655
8655
|
"summary": "CDK construct that provisions a PostgreSQL owner role on an Aurora cluster using a custom resource backed by the RDS Data API."
|
|
8656
8656
|
},
|
|
@@ -8665,7 +8665,7 @@
|
|
|
8665
8665
|
},
|
|
8666
8666
|
"locationInModule": {
|
|
8667
8667
|
"filename": "src/aurora-database-create-owner.ts",
|
|
8668
|
-
"line":
|
|
8668
|
+
"line": 82
|
|
8669
8669
|
},
|
|
8670
8670
|
"parameters": [
|
|
8671
8671
|
{
|
|
@@ -8700,7 +8700,7 @@
|
|
|
8700
8700
|
"kind": "class",
|
|
8701
8701
|
"locationInModule": {
|
|
8702
8702
|
"filename": "src/aurora-database-create-owner.ts",
|
|
8703
|
-
"line":
|
|
8703
|
+
"line": 73
|
|
8704
8704
|
},
|
|
8705
8705
|
"name": "AuroraDatabaseCreateOwner",
|
|
8706
8706
|
"symbolId": "src/aurora-database-create-owner:AuroraDatabaseCreateOwner"
|
|
@@ -8716,7 +8716,7 @@
|
|
|
8716
8716
|
"kind": "interface",
|
|
8717
8717
|
"locationInModule": {
|
|
8718
8718
|
"filename": "src/aurora-database-create-owner.ts",
|
|
8719
|
-
"line":
|
|
8719
|
+
"line": 40
|
|
8720
8720
|
},
|
|
8721
8721
|
"name": "AuroraDatabaseCreateOwnerProps",
|
|
8722
8722
|
"properties": [
|
|
@@ -8729,7 +8729,7 @@
|
|
|
8729
8729
|
"immutable": true,
|
|
8730
8730
|
"locationInModule": {
|
|
8731
8731
|
"filename": "src/aurora-database-create-owner.ts",
|
|
8732
|
-
"line":
|
|
8732
|
+
"line": 47
|
|
8733
8733
|
},
|
|
8734
8734
|
"name": "dbCluster",
|
|
8735
8735
|
"type": {
|
|
@@ -8746,7 +8746,7 @@
|
|
|
8746
8746
|
"immutable": true,
|
|
8747
8747
|
"locationInModule": {
|
|
8748
8748
|
"filename": "src/aurora-database-create-owner.ts",
|
|
8749
|
-
"line":
|
|
8749
|
+
"line": 45
|
|
8750
8750
|
},
|
|
8751
8751
|
"name": "dbMasterUserCredentials",
|
|
8752
8752
|
"type": {
|
|
@@ -8762,7 +8762,7 @@
|
|
|
8762
8762
|
"immutable": true,
|
|
8763
8763
|
"locationInModule": {
|
|
8764
8764
|
"filename": "src/aurora-database-create-owner.ts",
|
|
8765
|
-
"line":
|
|
8765
|
+
"line": 49
|
|
8766
8766
|
},
|
|
8767
8767
|
"name": "dbName",
|
|
8768
8768
|
"type": {
|
|
@@ -8779,7 +8779,7 @@
|
|
|
8779
8779
|
"immutable": true,
|
|
8780
8780
|
"locationInModule": {
|
|
8781
8781
|
"filename": "src/aurora-database-create-owner.ts",
|
|
8782
|
-
"line":
|
|
8782
|
+
"line": 54
|
|
8783
8783
|
},
|
|
8784
8784
|
"name": "ownerUsername",
|
|
8785
8785
|
"type": {
|
|
@@ -8793,7 +8793,7 @@
|
|
|
8793
8793
|
"assembly": "rds-aurora-bootstrapper",
|
|
8794
8794
|
"base": "constructs.Construct",
|
|
8795
8795
|
"docs": {
|
|
8796
|
-
"remarks": "On Create, the handler creates the schema (if missing), assigns ownership to\n{@link AuroraDatabaseCreateSchemaProps.ownerUsername}, and optionally drops\nthe `public` schema. The master username is derived from the `username` field\nof {@link AuroraDatabaseCreateSchemaProps.dbMasterUserCredentials} through a\nSecrets Manager dynamic reference; callers do not pass it explicitly.\n\nEnsure {@link AuroraDatabaseCreateSchemaProps.ownerUsername} already exists\n(for example via {@link AuroraDatabaseCreateOwner }) before this resource runs.",
|
|
8796
|
+
"remarks": "On Create, the handler creates the schema (if missing), assigns ownership to\n{@link AuroraDatabaseCreateSchemaProps.ownerUsername}, and optionally drops\nthe `public` schema. The master username is derived from the `username` field\nof {@link AuroraDatabaseCreateSchemaProps.dbMasterUserCredentials} through a\nSecrets Manager dynamic reference; callers do not pass it explicitly.\n\nEnsure {@link AuroraDatabaseCreateSchemaProps.ownerUsername} already exists\n(for example via {@link AuroraDatabaseCreateOwner }) before this resource runs.\n\nThe handler is a singleton Lambda shared with the other bootstrap constructs\nin the same stack.",
|
|
8797
8797
|
"stability": "stable",
|
|
8798
8798
|
"summary": "CDK construct that provisions a PostgreSQL schema on an Aurora cluster using a custom resource backed by the RDS Data API."
|
|
8799
8799
|
},
|
|
@@ -8808,7 +8808,7 @@
|
|
|
8808
8808
|
},
|
|
8809
8809
|
"locationInModule": {
|
|
8810
8810
|
"filename": "src/aurora-database-create-schema.ts",
|
|
8811
|
-
"line":
|
|
8811
|
+
"line": 104
|
|
8812
8812
|
},
|
|
8813
8813
|
"parameters": [
|
|
8814
8814
|
{
|
|
@@ -8843,7 +8843,7 @@
|
|
|
8843
8843
|
"kind": "class",
|
|
8844
8844
|
"locationInModule": {
|
|
8845
8845
|
"filename": "src/aurora-database-create-schema.ts",
|
|
8846
|
-
"line":
|
|
8846
|
+
"line": 95
|
|
8847
8847
|
},
|
|
8848
8848
|
"name": "AuroraDatabaseCreateSchema",
|
|
8849
8849
|
"symbolId": "src/aurora-database-create-schema:AuroraDatabaseCreateSchema"
|
|
@@ -8859,7 +8859,7 @@
|
|
|
8859
8859
|
"kind": "interface",
|
|
8860
8860
|
"locationInModule": {
|
|
8861
8861
|
"filename": "src/aurora-database-create-schema.ts",
|
|
8862
|
-
"line":
|
|
8862
|
+
"line": 52
|
|
8863
8863
|
},
|
|
8864
8864
|
"name": "AuroraDatabaseCreateSchemaProps",
|
|
8865
8865
|
"properties": [
|
|
@@ -8872,7 +8872,7 @@
|
|
|
8872
8872
|
"immutable": true,
|
|
8873
8873
|
"locationInModule": {
|
|
8874
8874
|
"filename": "src/aurora-database-create-schema.ts",
|
|
8875
|
-
"line":
|
|
8875
|
+
"line": 59
|
|
8876
8876
|
},
|
|
8877
8877
|
"name": "dbCluster",
|
|
8878
8878
|
"type": {
|
|
@@ -8889,7 +8889,7 @@
|
|
|
8889
8889
|
"immutable": true,
|
|
8890
8890
|
"locationInModule": {
|
|
8891
8891
|
"filename": "src/aurora-database-create-schema.ts",
|
|
8892
|
-
"line":
|
|
8892
|
+
"line": 57
|
|
8893
8893
|
},
|
|
8894
8894
|
"name": "dbMasterUserCredentials",
|
|
8895
8895
|
"type": {
|
|
@@ -8905,7 +8905,7 @@
|
|
|
8905
8905
|
"immutable": true,
|
|
8906
8906
|
"locationInModule": {
|
|
8907
8907
|
"filename": "src/aurora-database-create-schema.ts",
|
|
8908
|
-
"line":
|
|
8908
|
+
"line": 61
|
|
8909
8909
|
},
|
|
8910
8910
|
"name": "dbName",
|
|
8911
8911
|
"type": {
|
|
@@ -8922,7 +8922,7 @@
|
|
|
8922
8922
|
"immutable": true,
|
|
8923
8923
|
"locationInModule": {
|
|
8924
8924
|
"filename": "src/aurora-database-create-schema.ts",
|
|
8925
|
-
"line":
|
|
8925
|
+
"line": 66
|
|
8926
8926
|
},
|
|
8927
8927
|
"name": "ownerUsername",
|
|
8928
8928
|
"type": {
|
|
@@ -8939,7 +8939,7 @@
|
|
|
8939
8939
|
"immutable": true,
|
|
8940
8940
|
"locationInModule": {
|
|
8941
8941
|
"filename": "src/aurora-database-create-schema.ts",
|
|
8942
|
-
"line":
|
|
8942
|
+
"line": 76
|
|
8943
8943
|
},
|
|
8944
8944
|
"name": "publicSchema",
|
|
8945
8945
|
"type": {
|
|
@@ -8956,7 +8956,7 @@
|
|
|
8956
8956
|
"immutable": true,
|
|
8957
8957
|
"locationInModule": {
|
|
8958
8958
|
"filename": "src/aurora-database-create-schema.ts",
|
|
8959
|
-
"line":
|
|
8959
|
+
"line": 71
|
|
8960
8960
|
},
|
|
8961
8961
|
"name": "schemaName",
|
|
8962
8962
|
"type": {
|
|
@@ -8970,7 +8970,7 @@
|
|
|
8970
8970
|
"assembly": "rds-aurora-bootstrapper",
|
|
8971
8971
|
"base": "constructs.Construct",
|
|
8972
8972
|
"docs": {
|
|
8973
|
-
"remarks": "On Create, the handler creates a `LOGIN` role from\n{@link AuroraDatabaseCreateUserProps.targetUserCredentials} when the role is\nmissing, grants `CONNECT` on the database, `USAGE` on the schema, DML on\nexisting tables, and default privileges for future tables owned by\n{@link AuroraDatabaseCreateUserProps.ownerUsername}. Role creation is\nidempotent when the username already exists.\n\nThe master username is derived from the `username` field of\n{@link AuroraDatabaseCreateUserProps.dbMasterUserCredentials} through a\nSecrets Manager dynamic reference; callers do not pass it explicitly.\n\nEnsure {@link AuroraDatabaseCreateUserProps.ownerUsername} and\n{@link AuroraDatabaseCreateUserProps.schemaName} already exist (for example\nvia {@link AuroraDatabaseCreateOwner } and {@link AuroraDatabaseCreateSchema })\nbefore this resource runs.",
|
|
8973
|
+
"remarks": "On Create, the handler creates a `LOGIN` role from\n{@link AuroraDatabaseCreateUserProps.targetUserCredentials} when the role is\nmissing, grants `CONNECT` on the database, `USAGE` on the schema, DML on\nexisting tables, and default privileges for future tables owned by\n{@link AuroraDatabaseCreateUserProps.ownerUsername}. Role creation is\nidempotent when the username already exists.\n\nThe master username is derived from the `username` field of\n{@link AuroraDatabaseCreateUserProps.dbMasterUserCredentials} through a\nSecrets Manager dynamic reference; callers do not pass it explicitly.\n\nEnsure {@link AuroraDatabaseCreateUserProps.ownerUsername} and\n{@link AuroraDatabaseCreateUserProps.schemaName} already exist (for example\nvia {@link AuroraDatabaseCreateOwner } and {@link AuroraDatabaseCreateSchema })\nbefore this resource runs.\n\nThe handler is a singleton Lambda shared with the other bootstrap constructs\nin the same stack.",
|
|
8974
8974
|
"stability": "stable",
|
|
8975
8975
|
"summary": "CDK construct that provisions a PostgreSQL application user on an Aurora cluster using a custom resource backed by the RDS Data API."
|
|
8976
8976
|
},
|
|
@@ -8985,7 +8985,7 @@
|
|
|
8985
8985
|
},
|
|
8986
8986
|
"locationInModule": {
|
|
8987
8987
|
"filename": "src/aurora-database-create-user.ts",
|
|
8988
|
-
"line":
|
|
8988
|
+
"line": 101
|
|
8989
8989
|
},
|
|
8990
8990
|
"parameters": [
|
|
8991
8991
|
{
|
|
@@ -9020,7 +9020,7 @@
|
|
|
9020
9020
|
"kind": "class",
|
|
9021
9021
|
"locationInModule": {
|
|
9022
9022
|
"filename": "src/aurora-database-create-user.ts",
|
|
9023
|
-
"line":
|
|
9023
|
+
"line": 92
|
|
9024
9024
|
},
|
|
9025
9025
|
"name": "AuroraDatabaseCreateUser",
|
|
9026
9026
|
"symbolId": "src/aurora-database-create-user:AuroraDatabaseCreateUser"
|
|
@@ -9036,7 +9036,7 @@
|
|
|
9036
9036
|
"kind": "interface",
|
|
9037
9037
|
"locationInModule": {
|
|
9038
9038
|
"filename": "src/aurora-database-create-user.ts",
|
|
9039
|
-
"line":
|
|
9039
|
+
"line": 42
|
|
9040
9040
|
},
|
|
9041
9041
|
"name": "AuroraDatabaseCreateUserProps",
|
|
9042
9042
|
"properties": [
|
|
@@ -9049,7 +9049,7 @@
|
|
|
9049
9049
|
"immutable": true,
|
|
9050
9050
|
"locationInModule": {
|
|
9051
9051
|
"filename": "src/aurora-database-create-user.ts",
|
|
9052
|
-
"line":
|
|
9052
|
+
"line": 54
|
|
9053
9053
|
},
|
|
9054
9054
|
"name": "dbCluster",
|
|
9055
9055
|
"type": {
|
|
@@ -9066,7 +9066,7 @@
|
|
|
9066
9066
|
"immutable": true,
|
|
9067
9067
|
"locationInModule": {
|
|
9068
9068
|
"filename": "src/aurora-database-create-user.ts",
|
|
9069
|
-
"line":
|
|
9069
|
+
"line": 47
|
|
9070
9070
|
},
|
|
9071
9071
|
"name": "dbMasterUserCredentials",
|
|
9072
9072
|
"type": {
|
|
@@ -9082,7 +9082,7 @@
|
|
|
9082
9082
|
"immutable": true,
|
|
9083
9083
|
"locationInModule": {
|
|
9084
9084
|
"filename": "src/aurora-database-create-user.ts",
|
|
9085
|
-
"line":
|
|
9085
|
+
"line": 56
|
|
9086
9086
|
},
|
|
9087
9087
|
"name": "dbName",
|
|
9088
9088
|
"type": {
|
|
@@ -9099,7 +9099,7 @@
|
|
|
9099
9099
|
"immutable": true,
|
|
9100
9100
|
"locationInModule": {
|
|
9101
9101
|
"filename": "src/aurora-database-create-user.ts",
|
|
9102
|
-
"line":
|
|
9102
|
+
"line": 61
|
|
9103
9103
|
},
|
|
9104
9104
|
"name": "ownerUsername",
|
|
9105
9105
|
"type": {
|
|
@@ -9116,7 +9116,7 @@
|
|
|
9116
9116
|
"immutable": true,
|
|
9117
9117
|
"locationInModule": {
|
|
9118
9118
|
"filename": "src/aurora-database-create-user.ts",
|
|
9119
|
-
"line":
|
|
9119
|
+
"line": 66
|
|
9120
9120
|
},
|
|
9121
9121
|
"name": "schemaName",
|
|
9122
9122
|
"type": {
|
|
@@ -9133,7 +9133,7 @@
|
|
|
9133
9133
|
"immutable": true,
|
|
9134
9134
|
"locationInModule": {
|
|
9135
9135
|
"filename": "src/aurora-database-create-user.ts",
|
|
9136
|
-
"line":
|
|
9136
|
+
"line": 52
|
|
9137
9137
|
},
|
|
9138
9138
|
"name": "targetUserCredentials",
|
|
9139
9139
|
"type": {
|
|
@@ -9153,7 +9153,7 @@
|
|
|
9153
9153
|
"kind": "enum",
|
|
9154
9154
|
"locationInModule": {
|
|
9155
9155
|
"filename": "src/aurora-database-create-schema.ts",
|
|
9156
|
-
"line":
|
|
9156
|
+
"line": 42
|
|
9157
9157
|
},
|
|
9158
9158
|
"members": [
|
|
9159
9159
|
{
|
|
@@ -9175,6 +9175,6 @@
|
|
|
9175
9175
|
"symbolId": "src/aurora-database-create-schema:PublicSchema"
|
|
9176
9176
|
}
|
|
9177
9177
|
},
|
|
9178
|
-
"version": "0.
|
|
9179
|
-
"fingerprint": "
|
|
9178
|
+
"version": "0.6.0",
|
|
9179
|
+
"fingerprint": "bfkTsfG9xLQcUFdC37hcm9KeaXUO3csU3iJCaf/yBoc="
|
|
9180
9180
|
}
|
package/API.md
CHANGED
|
@@ -22,6 +22,9 @@ Ensure {@link AuroraDatabaseCreateMigratorProps.ownerUsername} and
|
|
|
22
22
|
example via {@link AuroraDatabaseCreateOwner } and
|
|
23
23
|
{@link AuroraDatabaseCreateSchema }) before this resource runs.
|
|
24
24
|
|
|
25
|
+
The handler is a singleton Lambda shared with the other bootstrap constructs
|
|
26
|
+
in the same stack.
|
|
27
|
+
|
|
25
28
|
#### Initializers <a name="Initializers" id="rds-aurora-bootstrapper.AuroraDatabaseCreateMigrator.Initializer"></a>
|
|
26
29
|
|
|
27
30
|
```typescript
|
|
@@ -165,10 +168,18 @@ The tree node.
|
|
|
165
168
|
|
|
166
169
|
CDK construct that provisions a PostgreSQL owner role on an Aurora cluster using a custom resource backed by the RDS Data API.
|
|
167
170
|
|
|
171
|
+
On Create, the handler creates a `NOLOGIN NOINHERIT` role when
|
|
172
|
+
{@link AuroraDatabaseCreateOwnerProps.ownerUsername} is missing, and grants
|
|
173
|
+
that role to the master user. Role creation is idempotent when the username
|
|
174
|
+
already exists.
|
|
175
|
+
|
|
168
176
|
The master username is derived from the `username` field of
|
|
169
177
|
{@link AuroraDatabaseCreateOwnerProps.dbMasterUserCredentials} through a
|
|
170
178
|
Secrets Manager dynamic reference; callers do not pass it explicitly.
|
|
171
179
|
|
|
180
|
+
The handler is a singleton Lambda shared with the other bootstrap constructs
|
|
181
|
+
in the same stack.
|
|
182
|
+
|
|
172
183
|
#### Initializers <a name="Initializers" id="rds-aurora-bootstrapper.AuroraDatabaseCreateOwner.Initializer"></a>
|
|
173
184
|
|
|
174
185
|
```typescript
|
|
@@ -321,6 +332,9 @@ Secrets Manager dynamic reference; callers do not pass it explicitly.
|
|
|
321
332
|
Ensure {@link AuroraDatabaseCreateSchemaProps.ownerUsername} already exists
|
|
322
333
|
(for example via {@link AuroraDatabaseCreateOwner }) before this resource runs.
|
|
323
334
|
|
|
335
|
+
The handler is a singleton Lambda shared with the other bootstrap constructs
|
|
336
|
+
in the same stack.
|
|
337
|
+
|
|
324
338
|
#### Initializers <a name="Initializers" id="rds-aurora-bootstrapper.AuroraDatabaseCreateSchema.Initializer"></a>
|
|
325
339
|
|
|
326
340
|
```typescript
|
|
@@ -480,6 +494,9 @@ Ensure {@link AuroraDatabaseCreateUserProps.ownerUsername} and
|
|
|
480
494
|
via {@link AuroraDatabaseCreateOwner } and {@link AuroraDatabaseCreateSchema })
|
|
481
495
|
before this resource runs.
|
|
482
496
|
|
|
497
|
+
The handler is a singleton Lambda shared with the other bootstrap constructs
|
|
498
|
+
in the same stack.
|
|
499
|
+
|
|
483
500
|
#### Initializers <a name="Initializers" id="rds-aurora-bootstrapper.AuroraDatabaseCreateUser.Initializer"></a>
|
|
484
501
|
|
|
485
502
|
```typescript
|
package/README.md
CHANGED
|
@@ -16,14 +16,15 @@ AWS CDK constructs for bootstrapping Aurora PostgreSQL databases via the RDS Dat
|
|
|
16
16
|
- **`AuroraDatabaseCreateUser`** — creates a `LOGIN` application user from a Secrets Manager credential secret, grants `CONNECT` / schema `USAGE` / table DML, and sets default privileges for the owner role
|
|
17
17
|
- **`AuroraDatabaseCreateMigrator`** — creates a `LOGIN` migrator user from a Secrets Manager credential secret, grants `CONNECT`, grants membership in the owner role, and sets `search_path` to the target schema
|
|
18
18
|
- Idempotent owner, user, and migrator role creation — skips creation when the role already exists
|
|
19
|
+
- Updating or deleting a construct leaves the role and schema in place
|
|
19
20
|
- Validates PostgreSQL identifiers at synthesis time (`ownerUsername`, `schemaName`)
|
|
20
21
|
- Resolves the master username from the credentials secret through a CloudFormation dynamic reference
|
|
21
22
|
|
|
22
23
|
## How it works
|
|
23
24
|
|
|
24
|
-
Add the constructs to a stack in order: owner role, schema, migrator user, then application user. On deploy,
|
|
25
|
+
Add the constructs to a stack in order: owner role, schema, migrator user, then application user. On deploy, the constructs share one Lambda function that calls the Aurora RDS Data API with the master credentials.
|
|
25
26
|
|
|
26
|
-
The owner construct creates a `NOLOGIN NOINHERIT` role and grants it to the master user. The schema construct creates the schema, assigns that owner, and either leaves or drops the `public` schema. The migrator construct creates a `LOGIN` role that belongs to the owner and uses the schema as `search_path`. The application user construct creates a `LOGIN` role with connect, schema usage, and table DML privileges. When a role already exists, creation is skipped.
|
|
27
|
+
The owner construct creates a `NOLOGIN NOINHERIT` role and grants it to the master user. The schema construct creates the schema, assigns that owner, and either leaves or drops the `public` schema. The migrator construct creates a `LOGIN` role that belongs to the owner and uses the schema as `search_path`. The application user construct creates a `LOGIN` role with connect, schema usage, and table DML privileges. When a role already exists, creation is skipped. Updating or deleting the custom resource does not drop the role or schema.
|
|
27
28
|
|
|
28
29
|
## Installation
|
|
29
30
|
|