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

BCDA-8360 add waf sync lambda #197

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

carlpartridge
Copy link
Collaborator

🎫 Ticket

https://jira.cms.gov/browse/BCDA-8360

🛠 Changes

Add WAF auto sync lambda

ℹ️ Context

We have recently switched over to WAF to control our allowlist of IP addresses. This lambda should sync our app DB with the source of truth on IP addresses to our WAF.

🧪 Validation

Local tests and linting passing.

@carlpartridge carlpartridge requested a review from a team December 30, 2024 15:01
@carlpartridge carlpartridge changed the title Carl/bcda 8360 add waf sync lambda BCDA-8360 add waf sync lambda Dec 30, 2024

err = rows.Scan(&ip)
if err != nil {
log.Warningf("Scan error: %+v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about bumping this to a fatal or error level? if scan fails on reading any of the IP set that should be updated, then that would mean that the IP allow list could be out of sync between database <> waf.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you think about bumping this to a fatal or error level? if scan fails on reading any of the IP set that should be updated, then that would mean that the IP allow list could be out of sync between database <> waf.

I think error makes more sense as we already return nil, err on issue here. Also I think returning fatal is not recommended in lambdas.

id: invoke-lambda
run: |
echo "STARTTIME=`date +%s`" >> "$GITHUB_OUTPUT"
aws lambda invoke --function-name bcda-dev-api-waf-sync test-result.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. if an error is returned; do we need to do any verification here or do we expect a non-zero exit code?
  2. do we want to add any additional validation for other cases where it runs successfully, but the end result might be different from what we expect; ie the update doesn't return an error, but there are no IPs in the WAF?

Copy link
Collaborator Author

@carlpartridge carlpartridge Jan 9, 2025

Choose a reason for hiding this comment

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

  1. I believe returning nonzero is enough but Im not entirely sure how to force the function to error out in order to test. I copied a lot of this code from the DPC version, maybe its worth pinging them?
  2. I feel like that would best be solved via splunk or cloudwatch alerts? They could watch for a variety of things based off the logs? I can create a ticket to look into this, either creating new alerts or modifying the jenkins alerts.

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