aws_dynamodb: allow point_in_time_recovery to be IResolvable
See original GitHub issueDescribe the feature
The point_in_time_recovery
field passed to the aws_dynamodb.Table constructor should also permit an IResolvable
to be passed.
The underlying CfnTable
resource already allows an IResolvable
for point_in_time_recovery_enabled
. https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_dynamodb/CfnTable.html#aws_cdk.aws_dynamodb.CfnTable.PointInTimeRecoverySpecificationProperty
Use Case
We want to use an Aspect to check that developers either enable point-in-time recovery for our production account, or explicitly disable it for all accounts. Currently, this is not feasible for two reasons:
- We cannot distinguish explicit disable from implicit disable.
- We cannot just hard-code
True
because it is contingent upon the account.
Instead, we want to make two implementations of IResolvable
. Then the Aspect can simply check that point_in_time_recovery_enabled
is set to an instance of once of these two classes.
Proposed Solution
Fix the Table
constructor to allow for IResolvable
for point_in_time_recovery
. If provided, it will generate the corresponding PointInTimeRecoverySpecificationProperty
instance.
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
1.140.0
Environment details (OS name and version, etc.)
Alpine 3.15
Issue Analytics
- State:
- Created a year ago
- Comments:21 (11 by maintainers)
No. I literally gave 3 different ways that do not involve any changes when adding a new Stack.
Again, no. See the
Stage
class example. You can also write a loop. There are a million ways to remove this duplication.OK. I think we’ve exhausted the discussion here. I really tried, but I can’t help more without seeing the code.
You obviously have some very strong opinions on how you want to structure your CDK code. I wish you luck, and I hope you manage to satisfy your requirements.
I’ve thought about it some more, and I think the answer is a custom Construct that wraps the CDK L2
Table
construct.This way, you can deal with setting
pointInTimeRecovery
to whatever you want by getting theCfnTable
underlying theTable
(using theNode.defaultChild
helper) - you probably want to use anFn::If
CloudFormation function, and possibly a Mapping too. This way, your developers will never have to know the details, and everything will happen automatically for them.Your Aspect can then validate that all DynamoDB Tables used in the App were created using your library, and not the
Table
class directly (here you can check for the presence your magicalIResolvable
subclass, that your custom Construct will use).