Skip to content

Add form snapshots scheduled task to forms-admin - #2370

Merged
theseanything merged 1 commit into
mainfrom
form-snapshots-scheduled-task
Oct 30, 2026
Merged

theseanything merged 1 commit into
mainfrom
form-snapshots-scheduled-task

Conversation

@theseanything

@theseanything theseanything commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this pull request solve?

Adds a daily forms-admin scheduled task that runs rake analytics:snapshot_forms (added in govuk-forms/forms-admin#3262) at 22:00 UTC. The task puts a row for every form to the form-snapshots-<env> Firehose stream added in #2359.

The forms-admin task role, which the scheduled tasks share with the service, can now call firehose:PutRecordBatch on that stream. The service also gets SETTINGS__ANALYTICS__FORM_SNAPSHOTS_STREAM_NAME, and the scheduled task inherits it. The stream ARN is built from its name, so the forms-admin root doesn't need to read the health root's state.

The task runs in every environment, with no setting to turn it off. It only writes to that environment's own analytics table, so it doesn't need to be limited to production the way the Mailchimp and organisations syncs are. There's no failure alert: a missed day shows up as a gap in the data, and the task can be rerun by hand.

Things to consider when reviewing

  • forms/health must be applied in each environment before this, so the stream exists before the first run.
  • No changes to the deployer role.

@theseanything
theseanything force-pushed the form-snapshots-scheduled-task branch from 3ac84b6 to dc83826 Compare October 30, 2026 10:47
Runs rake analytics:snapshot_forms at 22:00 UTC, after the working day
in both GMT and BST, so the UTC and UK dates of a snapshot are always
the same.

It runs in every environment. Unlike the Mailchimp and organisations
syncs it only writes to the environment's own analytics table, so there
is no reason to limit it to production, and running it in dev and
staging lets us check the data before it matters.

There is no failure alert: a missed day shows up as a gap in the data
and the task can be rerun by hand.

The stream ARN is built from its name so the forms-admin root doesn't
need the health root's state.

Each environment has its own AWS account, and the log group is already
per environment, so unlike the other scheduled tasks the names don't
include the environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@theseanything
theseanything force-pushed the form-snapshots-scheduled-task branch from dc83826 to 2b63037 Compare October 30, 2026 10:54
@theseanything
theseanything marked this pull request as ready for review October 30, 2026 11:05
Copilot AI balanced review requested due to automatic review settings October 30, 2026 11:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The scheduled-task deployment updater does not select the application container, so normal forms-admin deployments register new task revisions without updating the image.

1 open issue
What changed in this PR

Adds a daily forms-admin task to send form snapshots to the environment-specific analytics Firehose stream introduced in #2359.

Changes:

  • Schedules rake analytics:snapshot_forms at 22:00 UTC in every environment, without a failure alert.
  • Grants the shared task role firehose:PutRecordBatch access to the snapshots stream.
  • Supplies the stream name through an environment variable inherited by scheduled tasks.
File Description
infra/​modules/​forms-admin/​scheduled-tasks.tf Defines the daily form snapshots task and schedule.
infra/​modules/​forms-admin/​main.tf Adds the stream name, write permission, and application configuration.

Review effort: Balanced

@theseanything
theseanything added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit cc31ec1 Oct 30, 2026
23 checks passed
@theseanything
theseanything deleted the form-snapshots-scheduled-task branch October 30, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants