Add Lambda to requeue undownloaded granules #35
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I am changing
I've added the ability to requeue undownloaded granules for download when related download messages may have dropped off the main queue as well as the associated DLQ.
How I did it
I created a new standalone Lambda function that is deployed as part of the stack, but is not connected to any trigger/notification. It is intended solely for manual invocation. It expects 2 input values: (1) a date to use for querying the DB to find granules with an ingestion date matching the given date (but where downloaded=false), and (2) a "dry run" indicator (during a "dry run", undownloaded granules for the specified date are found, but not requeued).
How you can test it
To make it easy to run the Lambda function from the command line (without having to locate the "mangled" function name the CDK generates), you can use the shell script that I included.
When run from the root of the repo, the script will automatically source your
.env
file, which should include a value forIDENTIFIER
(or you can specify directly on the command line). It will locate the correct lambda function from the stack and construct a payload for invocation from the args supplied to the script.For example (assuming you either have
AWS_PROFILE
andIDENTIFIER
exported or configured in your.env
file):This will find all undownloaded granules with an ingestion date of 2023-06-10 and write the output to response.json. The output will include the inputs (dry run flag and date), along with the URL of the target queue, a count of the granules, and the list of granules (id, filename, and download URL for each).
After inspecting the results of a dry run, you may requeue the granules by rerunning the same command but by replacing the flag
--dry-run
with--no-dry-run
. One of the 2 flags must be specified. In order to reduce the chance of an accident, there is no default, forcing explicitness.