-
-
Notifications
You must be signed in to change notification settings - Fork 662
migrate runtime secrets from ssm to aws secrets manager #5141
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
Open
Mr-Rahul-Paul
wants to merge
57
commits into
OWASP:main
Choose a base branch
from
Mr-Rahul-Paul:fix#5071
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.
Open
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
c2aeee7
add migration mode
Mr-Rahul-Paul 50d55ed
preserve existing ssm resource
Mr-Rahul-Paul 9ec0817
create redis secret
Mr-Rahul-Paul 8225bf7
create redis secret#2
Mr-Rahul-Paul 31257bb
update outputs
Mr-Rahul-Paul 0965e1e
update cache test
Mr-Rahul-Paul d720ab5
remove ssm duplicate
Mr-Rahul-Paul 962e6e0
add move cause count makes it a list somehow
Mr-Rahul-Paul 136642a
update tests
Mr-Rahul-Paul 36b0fa3
update tests
Mr-Rahul-Paul 792de3b
update tests
Mr-Rahul-Paul af458e2
update tests ... again
Mr-Rahul-Paul 6279123
pass new secret arn into parameters
Mr-Rahul-Paul 8dc674f
add values to Live module
Mr-Rahul-Paul 9eef74b
Create application secrets:
Mr-Rahul-Paul 546f3dd
Make SSM secrets conditional
Mr-Rahul-Paul fe55862
Add state moves
Mr-Rahul-Paul b45cc30
update tests for counted resources
Mr-Rahul-Paul e700681
update tests for counted resources
Mr-Rahul-Paul a7903a5
update to provider-neutral ECS maps
Mr-Rahul-Paul b8ce020
corrections
Mr-Rahul-Paul 2e5fb58
rename the servicee input
Mr-Rahul-Paul 717713c
update container secrets
Mr-Rahul-Paul c0aa60f
add IAM permissions
Mr-Rahul-Paul 00fc7c4
Update live service calls
Mr-Rahul-Paul 46e5b8d
scheduled ECS task
Mr-Rahul-Paul bdcf905
test complete mode
Mr-Rahul-Paul e391caf
steps after AWS credentials
Mr-Rahul-Paul b86b44d
fixes
Mr-Rahul-Paul 037e38c
restore the deleted Redis endpoint output:
Mr-Rahul-Paul 987557a
extend iam permissions
Mr-Rahul-Paul 1ed6252
corrections + documenting cleanup
Mr-Rahul-Paul 96e8c2d
short sid cause there were size limits
Mr-Rahul-Paul 20978d1
ran terraform docs precommit
Mr-Rahul-Paul ff0289c
tflock update
Mr-Rahul-Paul 50b800e
Remove test-generated lockfile hashes
Mr-Rahul-Paul 4666110
Remove personal LocalStack fixture from PR
Mr-Rahul-Paul 5482a06
Omit empty Secrets Manager IAM statements
Mr-Rahul-Paul 95c1e6b
Scope runtime secret access by workload
Mr-Rahul-Paul 05b5eb0
Report runtime secret lookup failures accurately
Mr-Rahul-Paul d263f7b
Limit KMS decrypt to Secrets Manager
Mr-Rahul-Paul 52c55c8
Test runtime secret IAM policy scope
Mr-Rahul-Paul ed5e75f
Test complete-mode secret mappings
Mr-Rahul-Paul 0f725e0
Test removal of legacy database secret output
Mr-Rahul-Paul 8edc3e1
Clarify runtime secret migration documentation
Mr-Rahul-Paul 3a9a724
Avoid template injection in deploy workflow
Mr-Rahul-Paul fae495d
Add missing newline to cache output
Mr-Rahul-Paul 6fc617f
Address remaining secret migration review comments
Mr-Rahul-Paul c8aac6e
Test secret recovery window validation
Mr-Rahul-Paul 9a69d23
Test valid secret recovery window boundary
Mr-Rahul-Paul 6b76c8a
test(parameters): assert SSM source in prepare-mode container-secret …
Mr-Rahul-Paul ef88c0e
fix(deploy): default RUNTIME_SECRETS_MODE to prepare when env var is …
Mr-Rahul-Paul 42ab0e3
Merge remote-tracking branch 'upstream/main' into fix#5071
Mr-Rahul-Paul 4f436e2
add integration tests
Mr-Rahul-Paul 5792917
fmt
Mr-Rahul-Paul 475d833
new test assertion for github token format
Mr-Rahul-Paul 2d51487
fmt
Mr-Rahul-Paul 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| usage() { | ||
| echo "Usage: $0 <environment> <enable-additional-parameters>" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| [[ $# -eq 2 ]] || usage | ||
|
|
||
| environment=$1 | ||
| enable_additional_parameters=$2 | ||
|
|
||
| if [[ "$enable_additional_parameters" != "true" && "$enable_additional_parameters" != "false" ]]; then | ||
| usage | ||
| fi | ||
|
|
||
| check_secret() { | ||
| local secret_id=$1 | ||
| local secret_metadata | ||
|
|
||
| # Check version metadata without retrieving or printing the secret value. | ||
| if ! secret_metadata=$(aws secretsmanager describe-secret \ | ||
| --secret-id "$secret_id" \ | ||
| --query 'VersionIdsToStages' \ | ||
| --output json); then | ||
| echo "::error::Unable to describe required secret: ${secret_id}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! jq -e 'any(.[]; index("AWSCURRENT") != null)' <<<"$secret_metadata" >/dev/null; then | ||
| echo "::error::Secret has no AWSCURRENT version: ${secret_id}" >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| secret_names=( | ||
| DJANGO_ALGOLIA_WRITE_API_KEY | ||
| DJANGO_OPEN_AI_SECRET_KEY | ||
| DJANGO_REDIS_PASSWORD | ||
| DJANGO_SECRET_KEY | ||
| DJANGO_SENTRY_DSN | ||
| DJANGO_SLACK_BOT_TOKEN | ||
| DJANGO_SLACK_SIGNING_SECRET | ||
| GITHUB_TOKEN | ||
| NEXTAUTH_SECRET | ||
| NEXT_SERVER_GITHUB_CLIENT_SECRET | ||
| ) | ||
|
|
||
| if [[ "$enable_additional_parameters" == "true" ]]; then | ||
| secret_names+=(NEST_GITHUB_APP_PRIVATE_KEY SLACK_BOT_TOKEN_T04T40NHX) | ||
| fi | ||
|
|
||
| for secret_name in "${secret_names[@]}"; do | ||
| check_secret "/nest/${environment}/${secret_name}" | ||
| done | ||
|
|
||
| check_secret "nest-${environment}-db-credentials" | ||
|
|
||
|
Mr-Rahul-Paul marked this conversation as resolved.
|
||
| echo "All required runtime secrets have an AWSCURRENT version." | ||
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 |
|---|---|---|
|
|
@@ -307,7 +307,7 @@ data "aws_iam_policy_document" "part_two" { | |
| for_each = local.environments | ||
|
|
||
| statement { | ||
| sid = "AppAutoscalingManagement" | ||
| sid = "AppAutoscalingMgmt" | ||
|
Collaborator
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 shortened the Management suffix to |
||
| effect = "Allow" | ||
| actions = [ | ||
| "application-autoscaling:DeleteScalingPolicy", | ||
|
|
@@ -365,7 +365,7 @@ data "aws_iam_policy_document" "part_two" { | |
| } | ||
|
|
||
| statement { | ||
| sid = "ELBManagement" | ||
| sid = "ELBMgmt" | ||
| effect = "Allow" | ||
| actions = [ | ||
| "elasticloadbalancing:AddTags", | ||
|
|
@@ -393,7 +393,7 @@ data "aws_iam_policy_document" "part_two" { | |
| } | ||
|
|
||
| statement { | ||
| sid = "EventBridgeManagement" | ||
| sid = "EventBridgeMgmt" | ||
| effect = "Allow" | ||
| actions = [ | ||
| "events:DeleteRule", | ||
|
|
@@ -412,7 +412,7 @@ data "aws_iam_policy_document" "part_two" { | |
| } | ||
|
|
||
| statement { | ||
| sid = "IAMManagement" | ||
| sid = "IAMMgmt" | ||
| effect = "Allow" | ||
| actions = [ | ||
| "iam:AttachRolePolicy", | ||
|
|
@@ -471,7 +471,7 @@ data "aws_iam_policy_document" "part_two" { | |
| } | ||
|
|
||
| statement { | ||
| sid = "KMSManagement" | ||
| sid = "KMSMgmt" | ||
| effect = "Allow" | ||
| actions = [ | ||
| "kms:CreateKey", | ||
|
|
@@ -525,7 +525,7 @@ data "aws_iam_policy_document" "part_two" { | |
| } | ||
|
|
||
| statement { | ||
| sid = "S3Management" | ||
| sid = "S3Mgmt" | ||
| effect = "Allow" | ||
| actions = [ | ||
| "s3:CreateBucket", | ||
|
|
@@ -571,7 +571,7 @@ data "aws_iam_policy_document" "part_two" { | |
| } | ||
|
|
||
| statement { | ||
| sid = "SecretsManagerManagement" | ||
| sid = "SecretsManagerMgmt" | ||
| effect = "Allow" | ||
| actions = [ | ||
| "secretsmanager:CreateSecret", | ||
|
|
@@ -585,11 +585,14 @@ data "aws_iam_policy_document" "part_two" { | |
| "secretsmanager:UntagResource", | ||
| "secretsmanager:UpdateSecret", | ||
| ] | ||
| resources = ["arn:aws:secretsmanager:${var.aws_region}:${data.aws_caller_identity.current.account_id}:secret:${var.project_name}-${each.key}-*"] | ||
| resources = [ | ||
| "arn:aws:secretsmanager:${var.aws_region}:${data.aws_caller_identity.current.account_id}:secret:${var.project_name}-${each.key}-*", | ||
| "arn:aws:secretsmanager:${var.aws_region}:${data.aws_caller_identity.current.account_id}:secret:/${var.project_name}/${each.key}/*", | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "SSMManagement" | ||
| sid = "SSMMgmt" | ||
| effect = "Allow" | ||
| actions = [ | ||
| "ssm:AddTagsToResource", | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.