Open cs-thorsten opened 3 years ago
Hi @TMMeyer the CLI does not provide a way to do this out of the box. The options you've already mentioned are probably your best bet for achieving this. Marking as an enhancement.
There is a German proverb which says, "Hope is the last to die".
+1 Partially related to that: aws-amplify/amplify-category-api#235
Not sure if the amplify version you're on already has the override feature. If so, I believe you should be able to add an override like explained here and enable PITR for a specific model.
// override.ts
import { AmplifyApiGraphQlResourceStackTemplate } from '@aws-amplify/cli-extensibility-helper';
export function override(resources: AmplifyApiGraphQlResourceStackTemplate) {
resources.models['YourTable'].modelDDBTable.pointInTimeRecoverySpecification = {
pointInTimeRecoveryEnabled: true,
};
}
It's 2023 and this was very useful. I needed a way to turn on PITR across all of my Tables in my project. The issue is, I only want it "on" for staging and prod. NOT dev or any of our feature branches.
The best way I can imagine doing this is through an Amplify hook that can switch modes around the environment variable. I'll likely need to inject a change to PointInTimeRecoveryEnabled
in amplify/backend/api/<api-name>/parameters.json
.
I don't like doing this stuff because it's hard for future developers to track things down. Aside from that, is there a reason "NOT" to rely on amplify hooks in this way?
For those who happen upon this thread, I would suggest an amplify hook to call the CLI to enable PITR on a given table. Note: this will only work on build #s >1.
fyi the correct key name in paramaters.json
is DynamoDBEnablePointInTimeRecovery
Which Category is your question related to?
I want to activate PointInTimeRecovery for just one single table in the schema by CloudFormation.
Amplify CLI Version
4.44.0
What AWS Services are you utilizing?
AWS Amplify, Amazon DynamoDB, AWS CloudFormation, AWS CDK
Provide additional details e.g. code snippets
I know to enable PITR by setting
PointInTimeRecoveryEnabled
inamplify/backend/api/<api-name>/parameters.json
totrue
. But this enables PITR for all tables in the schema.I know to activate it maually either in the AWS DynmoDB Console or by CLI:
aws dynamodb update-continuous-backups --table-name myTable --point-in-time-recovery-specification PointInTimeRecoveryEnabled=True
But I want to define it in the template, so it can be deliverd to multiple environments without manual interaction.
As there is no annotation for the type in the
schema.graphql
file, we thought there might be a way to set it via Cloudformation inamplify/backend/api/<myapi>/stacks/CustomResources.json
but we did not find out yet.