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

Isolated lambdas, moved auth to secrets manager #137

Merged
merged 2 commits into from
Oct 28, 2024

Conversation

dogversioning
Copy link
Contributor

@dogversioning dogversioning commented Oct 28, 2024

  • Lambda reorg
    • Seperated all the lambdas into their own subfolders, and joined in the shared folder via symlink - this enable them to all be deployed seperately, which speeds up deployment in 90% of cases by a good clip
    • Removed the extra folder layer near the top of the tree
    • Updated cloudformation entrypoint to avoid reuploading the entire repo each time
    • did some import cleanup while i was in touching everything
  • Moved user logins to secrets manager (Change auth to use AWS secrets for storage #116)

There's a lot of files in this PR, but a good 90% of it is just renaming and adding symbolic links.

Copy link

github-actions bot commented Oct 28, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
692 657 95% 90% 🟢

New Files

File Coverage Status
src/dashboard/get_chart_data/init.py 100% 🟢
src/dashboard/get_csv/init.py 100% 🟢
src/dashboard/get_data_packages/init.py 100% 🟢
src/dashboard/get_metadata/init.py 100% 🟢
src/dashboard/get_study_periods/init.py 100% 🟢
src/shared/_init_.py 100% 🟢
src/site_upload/api_gateway_authorizer/init.py 100% 🟢
src/site_upload/cache_api/init.py 100% 🟢
src/site_upload/fetch_upload_url/init.py 100% 🟢
src/site_upload/powerset_merge/init.py 100% 🟢
src/site_upload/process_upload/init.py 100% 🟢
src/site_upload/study_period/init.py 100% 🟢
TOTAL 100% 🟢

Modified Files

No covered modified files...

updated for commit: 86581ff by action🐍

@@ -1,10 +1,11 @@
default_install_hook_types: [pre-commit, pre-push]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.5.7
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noting for posterity that ruff is now up to v0.7.1 - but here i'm just syncing this to this repo's version

@@ -26,26 +26,10 @@ def _put_s3_data(name: str, bucket_name: str, client, data: dict, path: str = "a
client.upload_fileobj(Bucket=bucket_name, Key=f"{path}/{name}", Fileobj=b_data)


def create_auth(client, bucket_name: str, user: str, auth: str, site: str) -> str:
def create_auth(client, user: str, auth: str, site: str) -> str:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is now just a convenience script for getting the password hash

Comment on lines 19 to 42
def get_secret():
"""Retrieves a specified secret.

This is largely unmodified boilerplate from the secrets manager recommended approach
for fetching secrets, except for getting the values from environment variables"""

secret_name = os.environ.get("SECRET_NAME")
region_name = os.environ.get("REGION")

session = boto3.session.Session()
client = session.client(service_name="secretsmanager", region_name=region_name)

try:
get_secret_value_response = client.get_secret_value(SecretId=secret_name)
except ClientError as e:
raise e

return json.loads(get_secret_value_response["SecretString"])


def lambda_handler(event, context):
del context
# ---- aggregator specific logic
user_db = get_s3_json_as_dict(
os.environ.get("BUCKET_NAME"), f"{BucketPath.ADMIN.value}/auth.json"
)
user_db = get_secret()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is section that is functionality change related to secrets.

scripts/credential_management.py Outdated Show resolved Hide resolved
@dogversioning dogversioning merged commit a3b4977 into main Oct 28, 2024
2 checks passed
@dogversioning dogversioning deleted the mg/secrets_manager branch October 28, 2024 19:45
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.

2 participants