-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Permissions error uploading prepared XML records to S3 #878
Labels
Comments
Adding some thoughts here related to the Additional considerations note in the issue description:
Options to consider:
|
This was referenced Sep 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why is this issue important?
We cannot save data from Grants.gov pertaining to new or modified grant opportunities. This issue currently only affects Staging.
Current State
As of the deployment of #848 to Staging, the
SplitGrantsGovXMLDB
Lambda function is unable to upload per-grant XML files to the S3 "prepared data" bucket. When the Lambda function attempts to do so, it receives anAccessDenied
response from S3 and logsError uploading prepared grant record to S3
(example logs, Datadog logs queryservice:grants-ingest "Error uploading prepared grant record to S3" functionname:grants_ingest-splitgrantsgovxmldb env:staging
). This issue appears to be due to incorrect/missing permissions in theSplitGrantsGovXMLDB
Lambda function execution role.Background: The changes in #848 introduced a new filename (object key) naming scheme for the S3 "prepared data" bucket. Previously, object keys for Grants.gov XML records always followed a pattern of
<id prefix>/<full id>/grants.gov/v2.xml
. Now, instead of/v2.xml
, object keys may have either of the following suffixes:/v2.OpportunitySynopsisDetail_1_0.xml
, for fully-published grant opportunity records/v2.OpportunityForecastDetail_1_0.xml
, for forecasted grant opportunity recordsHowever, the permissions for
SplitGrantsGovXMLDB
were never updated to match the new object key convention, so the Lambda function is still only allowed to inspect and upload S3 objects with the/v2.xml
suffix.Note: This issue is also causing errors later in the
PublishGrantEvents
step, as the missing Grants.gov data is causing validation failures. Resolving theSplitGrantsGovXMLDB
permissions issue should also resolve this downstreamPublishGrantEvents
validation issue.Expected State
The
SplitGrantsGovXMLDB
Lambda function is permitted to upload per-grant XML records to the S3 "prepared data" bucket using the new object key suffixes.Implementation Plan
Update permissions for Lambda execution role
In
terraform/modules/SplitGrantsGovXMLDB/main.tf
, update the Lambda function'sAllowInspectS3PreparedData
andAllowS3UploadPreparedData
execution policy statements so that theresources
condition in both statements' includes the following patterns:${data.aws_s3_bucket.prepared_data.arn}/*/*/grants.gov/v2.OpportunitySynopsisDetail_1_0.xml
${data.aws_s3_bucket.prepared_data.arn}/*/*/grants.gov/v2.OpportunityForecastDetail_1_0.xml
Refactor Last-Modified Determination in
SplitGrantsGovXMLDB
handler(See Option 3 in this comment)
We want to start using the "Grants Prepared Data" DynamoDB Table to determine whether an encountered XML record is new, modified, or unmodified. This replaces the existing behavior of checking S3 for the following conditions:
LastUpdatedDate
value: XML record is newer than the currently-persisted record and should replace the currently-persisted record in S3LastUpdatedDate
value: XML record has been seen before and is unchanged since the last time it was encountered bySplitGrantsGovXMLDB
When using DynamoDB, the behavior is basically the same:
LastUpdatedDate
value is older than the XML record'sLastUpdatedDate
value: XML record is newer than the currently-persisted table item, so the XML record should replace the currently-persisted record in S3, which will eventually result in an update to the corresponding DynamoDB table itemLastUpdatedDate
value is the same as (or more recent than) the XML record'sLastUpdatedDate
value: XML record has been seen before and is unchanged since the last time it was persisted to DynamoDB.Relevant Code Snippets
No response
The text was updated successfully, but these errors were encountered: