-
Notifications
You must be signed in to change notification settings - Fork 10
Replace PG_URL env var with Secrets Manager-based credential injection
#217
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
Draft
thejohnny
wants to merge
5
commits into
main
Choose a base branch
from
johnny/lambda-secrets-extension
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3671ba5
Replace `PG_URL` env var with Secrets Manager-based credential injection
thejohnny 04b63e9
Merge branch 'main' into johnny/lambda-secrets-extension
thejohnny 6f80ad2
Temporarily add archive provider to services submodule
thejohnny dd3515c
Resolve tflint warnings
thejohnny e5b7664
Remove postgres username and password from services submodule inputs
thejohnny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # Region must be one of: us-east-1, us-east-2, us-west-2, eu-west-1, ca-central-1, ap-southeast-2 | ||
| # ARNs: https://docs.aws.amazon.com/systems-manager/latest/userguide/ps-integration-lambda-extensions.html#ps-integration-lambda-extensions-add | ||
| locals { | ||
| secrets_ext_arns_arm64 = { | ||
| us-east-1 = { | ||
| arn = "arn:aws:lambda:us-east-1:177933569100:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64" | ||
| version = 61 | ||
| } | ||
| us-east-2 = { | ||
| arn = "arn:aws:lambda:us-east-2:590474943231:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64" | ||
| version = 67 | ||
| } | ||
| us-west-2 = { | ||
| arn = "arn:aws:lambda:us-west-2:345057560386:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64" | ||
| version = 61 | ||
| } | ||
|
Comment on lines
+3
to
+16
Collaborator
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. Can these be looked up? This isn't maintainable. |
||
| eu-west-1 = { | ||
| arn = "arn:aws:lambda:eu-west-1:015030872274:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64" | ||
| version = 63 | ||
| } | ||
| ca-central-1 = { | ||
| arn = "arn:aws:lambda:ca-central-1:200266452380:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64" | ||
| version = 62 | ||
| } | ||
| ap-southeast-2 = { | ||
| arn = "arn:aws:lambda:ap-southeast-2:665172237481:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64" | ||
| version = 63 | ||
| } | ||
| } | ||
|
|
||
| secrets_ext_arns_x86_64 = { | ||
| us-east-1 = { | ||
| arn = "arn:aws:lambda:us-east-1:177933569100:layer:AWS-Parameters-and-Secrets-Lambda-Extension" | ||
| version = 67 | ||
| } | ||
| us-east-2 = { | ||
| arn = "arn:aws:lambda:us-east-2:590474943231:layer:AWS-Parameters-and-Secrets-Lambda-Extension" | ||
| version = 73 | ||
| } | ||
| us-west-2 = { | ||
| arn = "arn:aws:lambda:us-west-2:345057560386:layer:AWS-Parameters-and-Secrets-Lambda-Extension" | ||
| version = 67 | ||
| } | ||
| eu-west-1 = { | ||
| arn = "arn:aws:lambda:eu-west-1:015030872274:layer:AWS-Parameters-and-Secrets-Lambda-Extension" | ||
| version = 63 | ||
| } | ||
| ca-central-1 = { | ||
| arn = "arn:aws:lambda:ca-central-1:200266452380:layer:AWS-Parameters-and-Secrets-Lambda-Extension" | ||
| version = 70 | ||
| } | ||
| ap-southeast-2 = { | ||
| arn = "arn:aws:lambda:ap-southeast-2:665172237481:layer:AWS-Parameters-and-Secrets-Lambda-Extension" | ||
| version = 63 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| data "aws_lambda_layer_version" "aws_params_secrets_arm64" { | ||
| layer_name = local.secrets_ext_arns_arm64[data.aws_region.current.id].arn | ||
| version = local.secrets_ext_arns_arm64[data.aws_region.current.id].version | ||
| } | ||
|
|
||
| data "aws_lambda_layer_version" "aws_params_secrets_x86_64" { | ||
| layer_name = local.secrets_ext_arns_x86_64[data.aws_region.current.id].arn | ||
| version = local.secrets_ext_arns_x86_64[data.aws_region.current.id].version | ||
| } | ||
|
|
||
| #----------------------------------------------------- | ||
| # TODO: relocate layer to `dist` and add to postbuild | ||
| #----------------------------------------------------- | ||
|
|
||
| data "archive_file" "secrets_wrapper_layer" { | ||
| type = "zip" | ||
| source_dir = "${path.module}/secrets-wrapper" | ||
| output_path = "${path.module}/.build/wrapper_layer.zip" | ||
| } | ||
|
|
||
| resource "aws_lambda_layer_version" "secrets_wrapper" { | ||
| layer_name = "secrets-env-wrapper" | ||
| description = "Exec wrapper that fetches Secrets Manager secrets and injects them as environment variables." | ||
| filename = data.archive_file.secrets_wrapper_layer.output_path | ||
| source_code_hash = data.archive_file.secrets_wrapper_layer.output_base64sha256 | ||
| compatible_runtimes = ["nodejs22.x", "python3.13"] | ||
|
|
||
| compatible_architectures = ["arm64", "x86_64"] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When
internal_observability_api_keyis set, this Lambda now attachesDatadog-Node22-xplus the ARM extension even thoughmigrate_databaserunspython3.13on the default x86_64 architecture. In that mode the update can fail due to incompatible layer architecture, and even if it deploys, the Python Datadog handler path (datadog_lambda.handler.handler) is missing the expected Python layer, so migration invocations break in observability-enabled environments.Useful? React with 👍 / 👎.