cdk-rds-sql 9.1.6__tar.gz → 9.2.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cdk-rds-sql
3
- Version: 9.1.6
3
+ Version: 9.2.0
4
4
  Summary: A CDK construct that allows creating roles or users and databases on Aurora Serverless PostgreSQL or MySQL/MariaDB clusters, as well as AWS DSQL clusters.
5
5
  Home-page: https://github.com/berenddeboer/cdk-rds-sql.git
6
6
  Author: Berend de Boer<berend@pobox.com>
@@ -333,6 +333,51 @@ const database = new Database(this, "Database", {
333
333
  })
334
334
  ```
335
335
 
336
+ ## Adopting existing roles and databases
337
+
338
+ A role or database that already exists makes `Role` and `Database`
339
+ fail on create. Set `ifNotExists` to adopt it instead, for example when
340
+ it moves to another stack and the old resource was retained:
341
+
342
+ ```python
343
+ const role = new Role(this, "Role", {
344
+ provider: provider,
345
+ roleName: "myrole",
346
+ databaseName: "mydb",
347
+ ifNotExists: true,
348
+ })
349
+
350
+ const database = new Database(this, "Database", {
351
+ provider: provider,
352
+ databaseName: "mydb",
353
+ owner: role,
354
+ ifNotExists: true,
355
+ })
356
+ ```
357
+
358
+ On PostgreSQL, a missing role or database is created as usual. An
359
+ existing role is altered to `login`, and with password authentication
360
+ it is given the password of the role's new secret. An existing database
361
+ only has its owner set. Grants are applied either way. MySQL already
362
+ creates users and databases with `IF NOT EXISTS`, so the property
363
+ changes nothing there. DSQL roles do not support it.
364
+
365
+ Adopting a password-authenticated role replaces its existing password.
366
+ Clients using the old credentials will need to switch to the new secret.
367
+
368
+ Only create changes: deleting the resource still drops the role or
369
+ database. To move one between stacks without dropping it, first deploy
370
+ the old resource with `RemovalPolicy.RETAIN`, then remove it and add
371
+ the new one with `ifNotExists`.
372
+
373
+ For adopted resources that should survive stack deletion, also apply
374
+ `RemovalPolicy.RETAIN` to the new `Role` and `Database` constructs.
375
+
376
+ On PostgreSQL, the existence check and creation can race with another
377
+ creator for both roles and databases. The role's `DO` block does not
378
+ serialize concurrent requests. Avoid concurrently creating the same
379
+ role or database from multiple stacks.
380
+
336
381
  ## Schema
337
382
 
338
383
  Create a schema in the default database as follows:
@@ -305,6 +305,51 @@ const database = new Database(this, "Database", {
305
305
  })
306
306
  ```
307
307
 
308
+ ## Adopting existing roles and databases
309
+
310
+ A role or database that already exists makes `Role` and `Database`
311
+ fail on create. Set `ifNotExists` to adopt it instead, for example when
312
+ it moves to another stack and the old resource was retained:
313
+
314
+ ```python
315
+ const role = new Role(this, "Role", {
316
+ provider: provider,
317
+ roleName: "myrole",
318
+ databaseName: "mydb",
319
+ ifNotExists: true,
320
+ })
321
+
322
+ const database = new Database(this, "Database", {
323
+ provider: provider,
324
+ databaseName: "mydb",
325
+ owner: role,
326
+ ifNotExists: true,
327
+ })
328
+ ```
329
+
330
+ On PostgreSQL, a missing role or database is created as usual. An
331
+ existing role is altered to `login`, and with password authentication
332
+ it is given the password of the role's new secret. An existing database
333
+ only has its owner set. Grants are applied either way. MySQL already
334
+ creates users and databases with `IF NOT EXISTS`, so the property
335
+ changes nothing there. DSQL roles do not support it.
336
+
337
+ Adopting a password-authenticated role replaces its existing password.
338
+ Clients using the old credentials will need to switch to the new secret.
339
+
340
+ Only create changes: deleting the resource still drops the role or
341
+ database. To move one between stacks without dropping it, first deploy
342
+ the old resource with `RemovalPolicy.RETAIN`, then remove it and add
343
+ the new one with `ifNotExists`.
344
+
345
+ For adopted resources that should survive stack deletion, also apply
346
+ `RemovalPolicy.RETAIN` to the new `Role` and `Database` constructs.
347
+
348
+ On PostgreSQL, the existence check and creation can race with another
349
+ creator for both roles and databases. The role's `DO` block does not
350
+ serialize concurrent requests. Avoid concurrently creating the same
351
+ role or database from multiple stacks.
352
+
308
353
  ## Schema
309
354
 
310
355
  Create a schema in the default database as follows:
@@ -5,7 +5,7 @@ kwargs = json.loads(
5
5
  """
6
6
  {
7
7
  "name": "cdk-rds-sql",
8
- "version": "9.1.6",
8
+ "version": "9.2.0",
9
9
  "description": "A CDK construct that allows creating roles or users and databases on Aurora Serverless PostgreSQL or MySQL/MariaDB clusters, as well as AWS DSQL clusters.",
10
10
  "license": "Apache-2.0",
11
11
  "url": "https://github.com/berenddeboer/cdk-rds-sql.git",
@@ -26,7 +26,7 @@ kwargs = json.loads(
26
26
  ],
27
27
  "package_data": {
28
28
  "cdk_rds_sql._jsii": [
29
- "cdk-rds-sql@9.1.6.jsii.tgz"
29
+ "cdk-rds-sql@9.2.0.jsii.tgz"
30
30
  ],
31
31
  "cdk_rds_sql": [
32
32
  "py.typed"
@@ -306,6 +306,51 @@ const database = new Database(this, "Database", {
306
306
  })
307
307
  ```
308
308
 
309
+ ## Adopting existing roles and databases
310
+
311
+ A role or database that already exists makes `Role` and `Database`
312
+ fail on create. Set `ifNotExists` to adopt it instead, for example when
313
+ it moves to another stack and the old resource was retained:
314
+
315
+ ```python
316
+ const role = new Role(this, "Role", {
317
+ provider: provider,
318
+ roleName: "myrole",
319
+ databaseName: "mydb",
320
+ ifNotExists: true,
321
+ })
322
+
323
+ const database = new Database(this, "Database", {
324
+ provider: provider,
325
+ databaseName: "mydb",
326
+ owner: role,
327
+ ifNotExists: true,
328
+ })
329
+ ```
330
+
331
+ On PostgreSQL, a missing role or database is created as usual. An
332
+ existing role is altered to `login`, and with password authentication
333
+ it is given the password of the role's new secret. An existing database
334
+ only has its owner set. Grants are applied either way. MySQL already
335
+ creates users and databases with `IF NOT EXISTS`, so the property
336
+ changes nothing there. DSQL roles do not support it.
337
+
338
+ Adopting a password-authenticated role replaces its existing password.
339
+ Clients using the old credentials will need to switch to the new secret.
340
+
341
+ Only create changes: deleting the resource still drops the role or
342
+ database. To move one between stacks without dropping it, first deploy
343
+ the old resource with `RemovalPolicy.RETAIN`, then remove it and add
344
+ the new one with `ifNotExists`.
345
+
346
+ For adopted resources that should survive stack deletion, also apply
347
+ `RemovalPolicy.RETAIN` to the new `Role` and `Database` constructs.
348
+
349
+ On PostgreSQL, the existence check and creation can race with another
350
+ creator for both roles and databases. The role's `DO` block does not
351
+ serialize concurrent requests. Avoid concurrently creating the same
352
+ role or database from multiple stacks.
353
+
309
354
  ## Schema
310
355
 
311
356
  Create a schema in the default database as follows:
@@ -692,6 +737,7 @@ class DatabaseEngine(enum.Enum):
692
737
  name_mapping={
693
738
  "database_name": "databaseName",
694
739
  "provider": "provider",
740
+ "if_not_exists": "ifNotExists",
695
741
  "owner": "owner",
696
742
  },
697
743
  )
@@ -701,22 +747,27 @@ class DatabaseProps:
701
747
  *,
702
748
  database_name: builtins.str,
703
749
  provider: "IProvider",
750
+ if_not_exists: typing.Optional[builtins.bool] = None,
704
751
  owner: typing.Optional["Role"] = None,
705
752
  ) -> None:
706
753
  '''
707
754
  :param database_name: Name of database to create.
708
755
  :param provider: Provider.
756
+ :param if_not_exists: Adopt the database if it already exists, instead of failing to create it. Use this to bring a database that already exists under this resource, for example when it moves to another stack and the old resource was retained. On create, PostgreSQL then checks ``pg_database`` first: a missing database is created as usual, and an existing one only has its owner set. MySQL already creates databases with ``IF NOT EXISTS``, so this changes nothing there. Only create is affected: update and delete behave as before, so deleting the resource still drops the database unless its removal policy retains it. Default: false - creating a database that already exists fails
709
757
  :param owner: Optional database owner.
710
758
  '''
711
759
  if __debug__:
712
760
  type_hints = cached_type_hints(_typecheckingstub__d02a87af93e26ceaf647662fc78818b2f43fe154b349df3c4f5752d22b61ea34)
713
761
  check_type(argname="argument database_name", value=database_name, expected_type=type_hints["database_name"])
714
762
  check_type(argname="argument provider", value=provider, expected_type=type_hints["provider"])
763
+ check_type(argname="argument if_not_exists", value=if_not_exists, expected_type=type_hints["if_not_exists"])
715
764
  check_type(argname="argument owner", value=owner, expected_type=type_hints["owner"])
716
765
  self._values: typing.Dict[builtins.str, typing.Any] = {
717
766
  "database_name": database_name,
718
767
  "provider": provider,
719
768
  }
769
+ if if_not_exists is not None:
770
+ self._values["if_not_exists"] = if_not_exists
720
771
  if owner is not None:
721
772
  self._values["owner"] = owner
722
773
 
@@ -734,6 +785,26 @@ class DatabaseProps:
734
785
  assert result is not None, "Required property 'provider' is missing"
735
786
  return typing.cast("IProvider", result)
736
787
 
788
+ @builtins.property
789
+ def if_not_exists(self) -> typing.Optional[builtins.bool]:
790
+ '''Adopt the database if it already exists, instead of failing to create it.
791
+
792
+ Use this to bring a database that already exists under this
793
+ resource, for example when it moves to another stack and the old
794
+ resource was retained. On create, PostgreSQL then checks
795
+ ``pg_database`` first: a missing database is created as usual, and an
796
+ existing one only has its owner set. MySQL already creates databases
797
+ with ``IF NOT EXISTS``, so this changes nothing there.
798
+
799
+ Only create is affected: update and delete behave as before, so
800
+ deleting the resource still drops the database unless its removal
801
+ policy retains it.
802
+
803
+ :default: false - creating a database that already exists fails
804
+ '''
805
+ result = self._values.get("if_not_exists")
806
+ return typing.cast(typing.Optional[builtins.bool], result)
807
+
737
808
  @builtins.property
738
809
  def owner(self) -> typing.Optional["Role"]:
739
810
  '''Optional database owner.'''
@@ -1387,6 +1458,7 @@ class Role(
1387
1458
  database_name: typing.Optional[builtins.str] = None,
1388
1459
  enable_iam_auth: typing.Optional[builtins.bool] = None,
1389
1460
  encryption_key: typing.Optional["_aws_cdk_aws_kms_ceddda9d.IKey"] = None,
1461
+ if_not_exists: typing.Optional[builtins.bool] = None,
1390
1462
  max_user_connections: typing.Optional[jsii.Number] = None,
1391
1463
  parameter_prefix: typing.Optional[builtins.str] = None,
1392
1464
  secret_name: typing.Optional[builtins.str] = None,
@@ -1400,6 +1472,7 @@ class Role(
1400
1472
  :param database_name: Optional database name this user is expected to use. If the database exists, connect privileges are granted. Specify one of ``database`` or ``databaseName``. This is the name that will be stored in the role's secret as the database name to use.
1401
1473
  :param enable_iam_auth: Enable IAM authentication for this role. When enabled, the role will be created without a password and configured for AWS IAM database authentication. No secret will be created for this role. Note: For DSQL clusters, this property is ignored as DSQL always uses IAM authentication. Default: false - use password authentication
1402
1474
  :param encryption_key: A new secret is created for this user. Optionally encrypt it with the given key.
1475
+ :param if_not_exists: Adopt the role if it already exists, instead of failing to create it. Use this to bring a role that already exists in the database under this resource, for example when it moves to another stack and the old resource was retained. On create, PostgreSQL then checks ``pg_roles`` first: a missing role is created as usual, an existing one is altered to ``login`` and, for password authentication, given the password of this role's secret. Grants are applied either way. MySQL already creates users with ``IF NOT EXISTS``, so this changes nothing there. DSQL does not support this property and throws if it is set. Only create is affected: update and delete behave as before, so deleting the resource still drops the role unless its removal policy retains it. Default: false - creating a role that already exists fails
1403
1476
  :param max_user_connections: Maximum simultaneous connections for this MySQL/MariaDB user. When set, create and update run ``ALTER USER '<roleName>'@'%' WITH MAX_USER_CONNECTIONS <n>``. A later change, including a smaller number, is applied on update. ``0`` restores the server default (unlimited unless the global ``max_user_connections`` is set). Omit the property to leave the user unlimited. Omitting it does not clear a limit that was already applied; set ``0`` to do that. PostgreSQL and DSQL do not support this property and throw if it is set. Default: undefined - no connection limit is applied
1404
1477
  :param parameter_prefix: Prefix for SSM parameters to store credentials in Parameter Store. When defined, credentials will also be stored as parameters. The parameter names such as "password" is simply appended to ``parameterPrefix``, so make sure the prefix ends with a slash if you have your parameter names slash separated. The password parameter is refreshed when CloudFormation updates the generated secret resource. Default: - credentials are only stored in Secrets Manager
1405
1478
  :param secret_name: A new secret is created for this user. Optionally add secret name to the secret.
@@ -1415,6 +1488,7 @@ class Role(
1415
1488
  database_name=database_name,
1416
1489
  enable_iam_auth=enable_iam_auth,
1417
1490
  encryption_key=encryption_key,
1491
+ if_not_exists=if_not_exists,
1418
1492
  max_user_connections=max_user_connections,
1419
1493
  parameter_prefix=parameter_prefix,
1420
1494
  secret_name=secret_name,
@@ -1454,6 +1528,7 @@ class Role(
1454
1528
  "database_name": "databaseName",
1455
1529
  "enable_iam_auth": "enableIamAuth",
1456
1530
  "encryption_key": "encryptionKey",
1531
+ "if_not_exists": "ifNotExists",
1457
1532
  "max_user_connections": "maxUserConnections",
1458
1533
  "parameter_prefix": "parameterPrefix",
1459
1534
  "secret_name": "secretName",
@@ -1469,6 +1544,7 @@ class RoleProps:
1469
1544
  database_name: typing.Optional[builtins.str] = None,
1470
1545
  enable_iam_auth: typing.Optional[builtins.bool] = None,
1471
1546
  encryption_key: typing.Optional["_aws_cdk_aws_kms_ceddda9d.IKey"] = None,
1547
+ if_not_exists: typing.Optional[builtins.bool] = None,
1472
1548
  max_user_connections: typing.Optional[jsii.Number] = None,
1473
1549
  parameter_prefix: typing.Optional[builtins.str] = None,
1474
1550
  secret_name: typing.Optional[builtins.str] = None,
@@ -1480,6 +1556,7 @@ class RoleProps:
1480
1556
  :param database_name: Optional database name this user is expected to use. If the database exists, connect privileges are granted. Specify one of ``database`` or ``databaseName``. This is the name that will be stored in the role's secret as the database name to use.
1481
1557
  :param enable_iam_auth: Enable IAM authentication for this role. When enabled, the role will be created without a password and configured for AWS IAM database authentication. No secret will be created for this role. Note: For DSQL clusters, this property is ignored as DSQL always uses IAM authentication. Default: false - use password authentication
1482
1558
  :param encryption_key: A new secret is created for this user. Optionally encrypt it with the given key.
1559
+ :param if_not_exists: Adopt the role if it already exists, instead of failing to create it. Use this to bring a role that already exists in the database under this resource, for example when it moves to another stack and the old resource was retained. On create, PostgreSQL then checks ``pg_roles`` first: a missing role is created as usual, an existing one is altered to ``login`` and, for password authentication, given the password of this role's secret. Grants are applied either way. MySQL already creates users with ``IF NOT EXISTS``, so this changes nothing there. DSQL does not support this property and throws if it is set. Only create is affected: update and delete behave as before, so deleting the resource still drops the role unless its removal policy retains it. Default: false - creating a role that already exists fails
1483
1560
  :param max_user_connections: Maximum simultaneous connections for this MySQL/MariaDB user. When set, create and update run ``ALTER USER '<roleName>'@'%' WITH MAX_USER_CONNECTIONS <n>``. A later change, including a smaller number, is applied on update. ``0`` restores the server default (unlimited unless the global ``max_user_connections`` is set). Omit the property to leave the user unlimited. Omitting it does not clear a limit that was already applied; set ``0`` to do that. PostgreSQL and DSQL do not support this property and throw if it is set. Default: undefined - no connection limit is applied
1484
1561
  :param parameter_prefix: Prefix for SSM parameters to store credentials in Parameter Store. When defined, credentials will also be stored as parameters. The parameter names such as "password" is simply appended to ``parameterPrefix``, so make sure the prefix ends with a slash if you have your parameter names slash separated. The password parameter is refreshed when CloudFormation updates the generated secret resource. Default: - credentials are only stored in Secrets Manager
1485
1562
  :param secret_name: A new secret is created for this user. Optionally add secret name to the secret.
@@ -1492,6 +1569,7 @@ class RoleProps:
1492
1569
  check_type(argname="argument database_name", value=database_name, expected_type=type_hints["database_name"])
1493
1570
  check_type(argname="argument enable_iam_auth", value=enable_iam_auth, expected_type=type_hints["enable_iam_auth"])
1494
1571
  check_type(argname="argument encryption_key", value=encryption_key, expected_type=type_hints["encryption_key"])
1572
+ check_type(argname="argument if_not_exists", value=if_not_exists, expected_type=type_hints["if_not_exists"])
1495
1573
  check_type(argname="argument max_user_connections", value=max_user_connections, expected_type=type_hints["max_user_connections"])
1496
1574
  check_type(argname="argument parameter_prefix", value=parameter_prefix, expected_type=type_hints["parameter_prefix"])
1497
1575
  check_type(argname="argument secret_name", value=secret_name, expected_type=type_hints["secret_name"])
@@ -1507,6 +1585,8 @@ class RoleProps:
1507
1585
  self._values["enable_iam_auth"] = enable_iam_auth
1508
1586
  if encryption_key is not None:
1509
1587
  self._values["encryption_key"] = encryption_key
1588
+ if if_not_exists is not None:
1589
+ self._values["if_not_exists"] = if_not_exists
1510
1590
  if max_user_connections is not None:
1511
1591
  self._values["max_user_connections"] = max_user_connections
1512
1592
  if parameter_prefix is not None:
@@ -1579,6 +1659,29 @@ class RoleProps:
1579
1659
  result = self._values.get("encryption_key")
1580
1660
  return typing.cast(typing.Optional["_aws_cdk_aws_kms_ceddda9d.IKey"], result)
1581
1661
 
1662
+ @builtins.property
1663
+ def if_not_exists(self) -> typing.Optional[builtins.bool]:
1664
+ '''Adopt the role if it already exists, instead of failing to create it.
1665
+
1666
+ Use this to bring a role that already exists in the database under
1667
+ this resource, for example when it moves to another stack and the
1668
+ old resource was retained. On create, PostgreSQL then checks
1669
+ ``pg_roles`` first: a missing role is created as usual, an existing
1670
+ one is altered to ``login`` and, for password authentication, given
1671
+ the password of this role's secret. Grants are applied either way.
1672
+ MySQL already creates users with ``IF NOT EXISTS``, so this changes
1673
+ nothing there. DSQL does not support this property and throws if it
1674
+ is set.
1675
+
1676
+ Only create is affected: update and delete behave as before, so
1677
+ deleting the resource still drops the role unless its removal
1678
+ policy retains it.
1679
+
1680
+ :default: false - creating a role that already exists fails
1681
+ '''
1682
+ result = self._values.get("if_not_exists")
1683
+ return typing.cast(typing.Optional[builtins.bool], result)
1684
+
1582
1685
  @builtins.property
1583
1686
  def max_user_connections(self) -> typing.Optional[jsii.Number]:
1584
1687
  '''Maximum simultaneous connections for this MySQL/MariaDB user.
@@ -1891,6 +1994,7 @@ class Database(
1891
1994
  *,
1892
1995
  database_name: builtins.str,
1893
1996
  provider: "IProvider",
1997
+ if_not_exists: typing.Optional[builtins.bool] = None,
1894
1998
  owner: typing.Optional["Role"] = None,
1895
1999
  ) -> None:
1896
2000
  '''
@@ -1898,6 +2002,7 @@ class Database(
1898
2002
  :param id: -
1899
2003
  :param database_name: Name of database to create.
1900
2004
  :param provider: Provider.
2005
+ :param if_not_exists: Adopt the database if it already exists, instead of failing to create it. Use this to bring a database that already exists under this resource, for example when it moves to another stack and the old resource was retained. On create, PostgreSQL then checks ``pg_database`` first: a missing database is created as usual, and an existing one only has its owner set. MySQL already creates databases with ``IF NOT EXISTS``, so this changes nothing there. Only create is affected: update and delete behave as before, so deleting the resource still drops the database unless its removal policy retains it. Default: false - creating a database that already exists fails
1901
2006
  :param owner: Optional database owner.
1902
2007
  '''
1903
2008
  if __debug__:
@@ -1905,7 +2010,10 @@ class Database(
1905
2010
  check_type(argname="argument scope", value=scope, expected_type=type_hints["scope"])
1906
2011
  check_type(argname="argument id", value=id, expected_type=type_hints["id"])
1907
2012
  props = DatabaseProps(
1908
- database_name=database_name, provider=provider, owner=owner
2013
+ database_name=database_name,
2014
+ provider=provider,
2015
+ if_not_exists=if_not_exists,
2016
+ owner=owner,
1909
2017
  )
1910
2018
 
1911
2019
  jsii.create(self.__class__, self, [scope, id, props])
@@ -1965,6 +2073,7 @@ def _typecheckingstub__d02a87af93e26ceaf647662fc78818b2f43fe154b349df3c4f5752d22
1965
2073
  *,
1966
2074
  database_name: builtins.str,
1967
2075
  provider: IProvider,
2076
+ if_not_exists: typing.Optional[builtins.bool] = None,
1968
2077
  owner: typing.Optional[Role] = None,
1969
2078
  ) -> None:
1970
2079
  """Type checking stubs"""
@@ -2068,6 +2177,7 @@ def _typecheckingstub__062afab8717d46f6fc2a31188b28d9e663190b2080174cc7f1ddd691f
2068
2177
  database_name: typing.Optional[builtins.str] = None,
2069
2178
  enable_iam_auth: typing.Optional[builtins.bool] = None,
2070
2179
  encryption_key: typing.Optional[_aws_cdk_aws_kms_ceddda9d.IKey] = None,
2180
+ if_not_exists: typing.Optional[builtins.bool] = None,
2071
2181
  max_user_connections: typing.Optional[jsii.Number] = None,
2072
2182
  parameter_prefix: typing.Optional[builtins.str] = None,
2073
2183
  secret_name: typing.Optional[builtins.str] = None,
@@ -2083,6 +2193,7 @@ def _typecheckingstub__a7ed79cdb7903207b3240698f6bcb0582905979c1519e2b49d66fa6fb
2083
2193
  database_name: typing.Optional[builtins.str] = None,
2084
2194
  enable_iam_auth: typing.Optional[builtins.bool] = None,
2085
2195
  encryption_key: typing.Optional[_aws_cdk_aws_kms_ceddda9d.IKey] = None,
2196
+ if_not_exists: typing.Optional[builtins.bool] = None,
2086
2197
  max_user_connections: typing.Optional[jsii.Number] = None,
2087
2198
  parameter_prefix: typing.Optional[builtins.str] = None,
2088
2199
  secret_name: typing.Optional[builtins.str] = None,
@@ -2140,6 +2251,7 @@ def _typecheckingstub__9b0a129482abaf744a12ee5aabac9c0545bc3cdf8edcfb3dca83d0c10
2140
2251
  *,
2141
2252
  database_name: builtins.str,
2142
2253
  provider: IProvider,
2254
+ if_not_exists: typing.Optional[builtins.bool] = None,
2143
2255
  owner: typing.Optional[Role] = None,
2144
2256
  ) -> None:
2145
2257
  """Type checking stubs"""
@@ -18,7 +18,7 @@ import aws_cdk._jsii
18
18
  import constructs._jsii
19
19
 
20
20
  __jsii_assembly__ = jsii.JSIIAssembly.load(
21
- "cdk-rds-sql", "9.1.6", __name__[0:-6], "cdk-rds-sql@9.1.6.jsii.tgz"
21
+ "cdk-rds-sql", "9.2.0", __name__[0:-6], "cdk-rds-sql@9.2.0.jsii.tgz"
22
22
  )
23
23
 
24
24
  __all__ = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cdk-rds-sql
3
- Version: 9.1.6
3
+ Version: 9.2.0
4
4
  Summary: A CDK construct that allows creating roles or users and databases on Aurora Serverless PostgreSQL or MySQL/MariaDB clusters, as well as AWS DSQL clusters.
5
5
  Home-page: https://github.com/berenddeboer/cdk-rds-sql.git
6
6
  Author: Berend de Boer<berend@pobox.com>
@@ -333,6 +333,51 @@ const database = new Database(this, "Database", {
333
333
  })
334
334
  ```
335
335
 
336
+ ## Adopting existing roles and databases
337
+
338
+ A role or database that already exists makes `Role` and `Database`
339
+ fail on create. Set `ifNotExists` to adopt it instead, for example when
340
+ it moves to another stack and the old resource was retained:
341
+
342
+ ```python
343
+ const role = new Role(this, "Role", {
344
+ provider: provider,
345
+ roleName: "myrole",
346
+ databaseName: "mydb",
347
+ ifNotExists: true,
348
+ })
349
+
350
+ const database = new Database(this, "Database", {
351
+ provider: provider,
352
+ databaseName: "mydb",
353
+ owner: role,
354
+ ifNotExists: true,
355
+ })
356
+ ```
357
+
358
+ On PostgreSQL, a missing role or database is created as usual. An
359
+ existing role is altered to `login`, and with password authentication
360
+ it is given the password of the role's new secret. An existing database
361
+ only has its owner set. Grants are applied either way. MySQL already
362
+ creates users and databases with `IF NOT EXISTS`, so the property
363
+ changes nothing there. DSQL roles do not support it.
364
+
365
+ Adopting a password-authenticated role replaces its existing password.
366
+ Clients using the old credentials will need to switch to the new secret.
367
+
368
+ Only create changes: deleting the resource still drops the role or
369
+ database. To move one between stacks without dropping it, first deploy
370
+ the old resource with `RemovalPolicy.RETAIN`, then remove it and add
371
+ the new one with `ifNotExists`.
372
+
373
+ For adopted resources that should survive stack deletion, also apply
374
+ `RemovalPolicy.RETAIN` to the new `Role` and `Database` constructs.
375
+
376
+ On PostgreSQL, the existence check and creation can race with another
377
+ creator for both roles and databases. The role's `DO` block does not
378
+ serialize concurrent requests. Avoid concurrently creating the same
379
+ role or database from multiple stacks.
380
+
336
381
  ## Schema
337
382
 
338
383
  Create a schema in the default database as follows:
@@ -11,4 +11,4 @@ src/cdk_rds_sql.egg-info/dependency_links.txt
11
11
  src/cdk_rds_sql.egg-info/requires.txt
12
12
  src/cdk_rds_sql.egg-info/top_level.txt
13
13
  src/cdk_rds_sql/_jsii/__init__.py
14
- src/cdk_rds_sql/_jsii/cdk-rds-sql@9.1.6.jsii.tgz
14
+ src/cdk_rds_sql/_jsii/cdk-rds-sql@9.2.0.jsii.tgz
File without changes
File without changes
File without changes
File without changes