-
Notifications
You must be signed in to change notification settings - Fork 51
Use FIPs endpoints in Govcloud regions #575
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
Changes from 3 commits
a41cbb3
ca7e5c5
bbf8042
0c4fdc4
6d5ff78
f054e22
af87910
7fdd7e8
6396cef
7411cf2
2b02f02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,16 +64,31 @@ def get_api_key() -> str: | |
| DD_KMS_API_KEY = os.environ.get("DD_KMS_API_KEY", "") | ||
| DD_API_KEY = os.environ.get("DD_API_KEY", os.environ.get("DATADOG_API_KEY", "")) | ||
|
|
||
| REGION = os.environ.get("AWS_REGION", "") | ||
| is_gov_region = REGION.startswith("us-gov-") | ||
| if is_gov_region: | ||
| logger.info("Govcloud region detected. Using FIPs endpoints for secrets management.") | ||
|
|
||
|
Comment on lines
+69
to
+73
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you really want to log it, use debug, I don't think we should add
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm open to changing it to debug, but just in case you didn't see my justification:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did see it, I still stand by the same point. This still directly impacts billing, even though the scope is just once per (I imagine cold starts) execution context on GovCloud. |
||
| if DD_API_KEY_SECRET_ARN: | ||
| api_key = boto3.client("secretsmanager").get_secret_value( | ||
| # Secrets manager endpoints: https://docs.aws.amazon.com/general/latest/gr/asm.html | ||
| fips_endpoint = f"https://secretsmanager-fips.{REGION}.amazonaws.com" if is_gov_region else None | ||
| secrets_manager_client = boto3.client( | ||
| "secretsmanager", endpoint_url=fips_endpoint | ||
| ) | ||
| api_key = secrets_manager_client.get_secret_value( | ||
| SecretId=DD_API_KEY_SECRET_ARN | ||
| )["SecretString"] | ||
| elif DD_API_KEY_SSM_NAME: | ||
| api_key = boto3.client("ssm").get_parameter( | ||
| # SSM endpoints: https://docs.aws.amazon.com/general/latest/gr/ssm.html | ||
| fips_endpoint = f"https://ssm-fips.{REGION}.amazonaws.com" if is_gov_region else None | ||
| ssm_client = boto3.client("ssm", endpoint_url=fips_endpoint) | ||
| api_key = ssm_client.get_parameter( | ||
| Name=DD_API_KEY_SSM_NAME, WithDecryption=True | ||
| )["Parameter"]["Value"] | ||
| elif DD_KMS_API_KEY: | ||
| kms_client = boto3.client("kms") | ||
| # KMS endpoints: https://docs.aws.amazon.com/general/latest/gr/kms.html | ||
| fips_endpoint = f"https://kms-fips.{REGION}.amazonaws.com" if is_gov_region else None | ||
| kms_client = boto3.client("kms",endpoint_url=fips_endpoint) | ||
| api_key = decrypt_kms_api_key(kms_client, DD_KMS_API_KEY) | ||
| else: | ||
| api_key = DD_API_KEY | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging on
infolevel here makes sense because this only runs once per Lambda execution context, and this only occurs in Govcloud regions where FIPs endpoints does matter to our users