All jobs

Turn On DynamoDB Point-in-Time Recovery in a Serverless Framework Service

Yes. An agent finds every DynamoDB table in your serverless.yml files, turns on point-in-time recovery, keeps tables on stack removal, lints the YAML and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads every service definition before changing one. In a repository laid out like serverless/examples, 111 directories each hold a serverless.yml on frameworkVersion 4, and 21 of them declare an AWS::DynamoDB::Table under resources.Resources: Node services on nodejs24.x such as aws-node-express-dynamodb-api and aws-node-http-api-dynamodb, Python services on python3.14 such as aws-python-rest-api-with-dynamodb, Ruby services on ruby4.0 including aws-ruby-step-functions, which declares two tables, and a Go service on provided.al2023. Most tables use BillingMode: PAY_PER_REQUEST; six still set ProvisionedThroughput. Thirteen carry DeletionPolicy: Retain, eight do not, and none sets PointInTimeRecoverySpecification, so a table in any of them can be restored only to a backup someone made by hand.

For each table the agent adds PointInTimeRecoverySpecification with PointInTimeRecoveryEnabled: true under Properties, which turns on continuous backups with a 35-day window that DynamoDB manages. It then adds DeletionPolicy: Retain where it is missing and UpdateReplacePolicy: Retain everywhere, because point-in-time recovery lives with the table: a serverless remove, or a change to TableName that makes CloudFormation replace the resource, would otherwise delete the table and its recovery window together. The aws-node-express-dynamodb-api README already tells readers to add DeletionPolicy: Retain themselves; the agent makes that the default and updates the sentence.

The IAM statements that reference each table through Fn::GetAtt on its ARN, the TableName built from ${self:service}-${sls:stage} or a stage parameter, and the environment variables the handlers read are left alone, since recovery is a table property and changes no request path. For the six provisioned tables the agent changes nothing about capacity: switching billing mode is a cost decision for the service owner, and the pull request says so beside each one.

The Serverless Framework v4 command line signs in before it packages anything, so the agent does not rely on it in the sandbox. Instead it loads each edited serverless.yml, renders the resources.Resources block to a CloudFormation template with the framework's ${...} variables replaced by placeholder strings, and runs cfn-lint over the result, which checks the property name and the shape of the new specification against the AWS resource schema. It also runs the repository's own npm run validate and npm run check-docs, which assert each example's README front matter and keep examples.json and the root README in step, since the edited READMEs must still pass them.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Enable DynamoDB point-in-time recovery across this repository's Serverless Framework services. Find every serverless.yml that declares an AWS::DynamoDB::Table and list them with their runtime, billing mode and current DeletionPolicy before editing. For each table add PointInTimeRecoverySpecification with PointInTimeRecoveryEnabled: true under Properties, add DeletionPolicy: Retain where it is missing and UpdateReplacePolicy: Retain everywhere, and leave billing mode, capacity, TableName, IAM statements and environment variables unchanged. Where a README tells the reader to add DeletionPolicy themselves, update that sentence. Render each edited resources block to a CloudFormation template with placeholders for ${...} variables and run cfn-lint over it; also run npm run validate and npm run check-docs from the root. Open a pull request with one section per service naming the table, what changed, and whether it is provisioned or on-demand.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

The pull request changes the serverless.yml of each service that declares a table and the README of any service whose text described the old behaviour. Its description has one section per service with the table's logical id, the lines added, the billing mode it keeps, and the cfn-lint result for its rendered template, plus the output of npm run validate and npm run check-docs from the root.

On the next serverless deploy of each service, CloudFormation updates the table in place: enabling recovery and changing deletion policies are updates, not replacements, so no data moves and no endpoint changes. From then on, a serverless remove leaves the table behind with its recovery window intact, and a restore to any second in the previous 35 days is an AWS console or CLI action on that table.

Before merging, a reviewer checks the six provisioned tables for whether on-demand billing should change in the same pull request, decides whether retained tables need a note in each README about cleaning them up by hand after a serverless remove, and confirms that any deployment pipeline with a stack-delete step expects tables to survive it.

Run it on every new service

A platform team that owns many Serverless Framework services sends this body once per repository from its own server, each a POST /o/{org}/sessions with that repository in resources and a request_id that is a UUID v5 of the repository's full name, so a retried call returns the run already started. Each run reads its own files: a repository with one service gets one section, a monorepo gets one per serverless.yml, and a table that already has recovery on is reported and left alone.

Once the baseline is set, an automation on the Project with a github trigger on pull_request.opened and pull_request.synchronize and the prompt "if this pull request adds an AWS::DynamoDB::Table to any serverless.yml without PointInTimeRecoverySpecification or a Retain deletion policy, comment with the exact lines to add; push nothing" starts one run per push. The trigger adds the pull request after the prompt, only work by an owner, member or collaborator fires it, and its runs read the repository and comment, so no new table reaches a deploy without the setting.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

The edit is four lines per table; the work is finding every table across a hundred services, knowing which ones a rename would replace, and proving the CloudFormation is right without an AWS account in the loop. The agent does the survey in one pass, keeps the per-table list it made, and validates each rendered template with cfn-lint so the first deploy is not the first test.

Every command the agent runs, from the table survey to npm run check-docs, stays with the run as evidence, and the pull request reads as a per-service inventory rather than a diff to decode. A team with many repositories runs the same request across all of them at once, each in its own sandbox, and gets one inventory per repository.

Frequently asked questions

Does enabling point-in-time recovery replace or interrupt the table?

No. PointInTimeRecoverySpecification is an updatable property, so CloudFormation turns it on in place during the next deploy, and reads and writes continue. The same is true of DeletionPolicy and UpdateReplacePolicy, which are resource attributes rather than table settings.

Why add UpdateReplacePolicy when DeletionPolicy is already there?

DeletionPolicy covers stack deletion; UpdateReplacePolicy covers an update that replaces the resource, which a change to TableName or a key schema causes. Without it, a rename would create a new empty table and delete the old one with its recovery window, which is the loss the setting exists to prevent.

Why not run serverless package to validate?

The v4 command line asks for a Serverless account before it packages or prints a service, and the sandbox has no credentials to give it. Rendering the resources block with placeholders and running cfn-lint checks the property names and shapes the framework would pass to CloudFormation without that sign-in.

Will the provisioned tables be switched to on-demand?

No. The six services that set ProvisionedThroughput keep it, and the pull request marks each one so the owner can decide separately; billing mode changes cost and throughput behaviour, while recovery and retention do not.

What does the change cost?

Continuous backups are billed by the size of the table's data on AWS's own schedule, and the agent writes no estimate because it has not read the tables. The pull request points to each table's TableName so an owner can look up its size in the console before merging.

More Serverless Framework jobs

The same job on other stacks

More jobs like this: Hand off a long task

Keep reading