Skip to content
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

Feature/issue 78 VPC Endpoint for Dynamo #110

Merged
merged 8 commits into from
Mar 27, 2024
Merged

Conversation

nikki-t
Copy link
Collaborator

@nikki-t nikki-t commented Mar 7, 2024

Github Issue: #78

Description

Configure the timeseries, load_data and load_data-granule Lambda functions for VPC access. This will ensure that Lambda network traffic is isolated to a single VPC and traverse the DynamoDB VPC endpoint created by NGAP.

Overview of work done

Configured all three Lambda functions for VPC access.

This required an update to the AWS provider (~> 4.0) and the Terraform CLI (1.7.3).

Overview of verification done

Existing functionality is not impacted and current unit tests pass.

Overview of integration done

Configuration was deployed to the SIT environment and confirmed existing functionality.

Reach GeoJSON request:

{"status":"200 OK","time":239.655,"hits":3,"results":{"csv":"","geojson":{"type":"FeatureCollection","features":[{"properties":{"reach_id":"73282400171","time_str":"2023-07-28T22:10:37Z","wse":"211.178","slope":"-0.0007516914999999999"},"geometry":{},"type":"Feature"},{"properties":{"reach_id":"73282400171","time_str":"2023-09-08T15:40:49Z","wse":"82.082","slope":"-1.0184e-06"},"geometry":{},"type":"Feature"},{"properties":{"reach_id":"73282400171","time_str":"2023-09-29T12:25:52Z","wse":"206.49349999999998","slope":"-0.0007833485000000001"},"geometry":{},"type":"Feature"}]}}}

Set up flow logs for the timeseries Lambda function elastic network interface and confirmed data traversing the interface and sending/receiving data from an IP address in the CIDR range for the DynamoDB Endpoint.

Example log:

2024-03-14T10:47:48.000-04:00 2 <ACCOUNT_ID> eni-xxxxxxxx <DYNAMODB> <LAMBDA> 443 12133 6 217 253126 1710427668 1710427669 ACCEPT OK
2024-03-14T10:47:48.000-04:00 2 <ACCOUNT_ID> eni-xxxxxxxx <LAMBDA> <DYNAMODB> 12133 443 6 153 64613 1710427668 1710427669 ACCEPT OK

Ran Reachability Analyzer with the Lambda function's elastic network interface as the source and the DynamoDB VPC Endpoint as the destination and confirmed traffic can get from the Lambda function to the Endpoint.

PR checklist:

  • Linted
  • Updated unit tests
  • Updated changelog
  • Integration testing

See Pull Request Review Checklist for pointers on reviewing this pull request

@nikki-t nikki-t requested review from torimcd and vggonzal March 7, 2024 22:10
@nikki-t nikki-t self-assigned this Mar 7, 2024
@frankinspace frankinspace changed the title Feature/issue 78 Feature/issue 78 VPC Endpoint for Dynamo Mar 7, 2024
@nikki-t
Copy link
Collaborator Author

nikki-t commented Mar 14, 2024

I was able to confirm VPC configuration for the Lambda and view traffic traversing the elastic network interface associated with the Lambda. I can see the Lambda's elastic network interface IP address querying an IP address in one of the CIDR ranges associated with the DynamoDB VPC endpoint and I can see the return response from the endpoint to the Lambda function. I am waiting on final confirmation from AWS Support and will set the PR as ready for review.

@nikki-t nikki-t requested a review from frankinspace March 15, 2024 15:39
@nikki-t
Copy link
Collaborator Author

nikki-t commented Mar 15, 2024

Confirmed configuration with AWS support and ran a reachability analysis to see if the Lambda function elastic network interface can reach the DynamoDB VPC Endpoint.

@torimcd - do you want to run a test in the SIT environment for the database operations to make sure everything still functions as it should? I have the feature/issue-78 branch currently deployed to that environment.

terraform/versions.tf Outdated Show resolved Hide resolved
@@ -22,7 +22,7 @@ pymysql = "^1.1.0"
geopandas = "^0.13.2"
earthaccess = "^0.5.3"
shapely = "^2.0.1"
cryptography = "^41.0.2"
cryptography = "42.0.0"
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need this? I just removed it in one of the other branches and things seemed to work fine.

Suggested change
cryptography = "42.0.0"

frankinspace and others added 2 commits March 18, 2024 11:32
Co-authored-by: Frank Greguska <89428916+frankinspace@users.noreply.github.com>
Copy link
Collaborator

@torimcd torimcd left a comment

Choose a reason for hiding this comment

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

Looks good to me, tested the db operations in SIT and everything works as it should.

@nikki-t nikki-t marked this pull request as ready for review March 20, 2024 13:24
@nikki-t
Copy link
Collaborator Author

nikki-t commented Mar 20, 2024

Thanks @torimcd for testing the db operations in SIT. I think this is ready to be merged unless we want to wait and add the VPC configuration to the cnm_handler Lambda?

@torimcd
Copy link
Collaborator

torimcd commented Mar 20, 2024

@nikki-t the cnm_handler lambda only invokes the load_granule lambda, it doesn't interact with dynamodb directly. Not sure how that effects whether or not to include in the vpc?

@nikki-t
Copy link
Collaborator Author

nikki-t commented Mar 20, 2024

@torimcd - That makes sense. I wasn't sure if we wanted all of our Lambdas configured for the VPC or maybe it's preferable to only configure the ones with DynamoDB access for the VPC? @frankinspace - Do you have a preference?

Copy link
Member

@frankinspace frankinspace left a comment

Choose a reason for hiding this comment

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

If it's not accessing dynamo no need to be in VPC

@frankinspace frankinspace merged commit 1ae5f5d into develop Mar 27, 2024
7 checks passed
@frankinspace frankinspace deleted the feature/issue-78 branch March 27, 2024 21:22
@nikki-t nikki-t linked an issue Mar 27, 2024 that may be closed by this pull request
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.

Use a VPC endpoint and policies to access DynamoDB
3 participants