feat: inject API keys from Secrets Manager into ECS task definitions#64
Merged
0b00101111 merged 2 commits intomainfrom Mar 28, 2026
Merged
feat: inject API keys from Secrets Manager into ECS task definitions#640b00101111 merged 2 commits intomainfrom
0b00101111 merged 2 commits intomainfrom
Conversation
…asks ECS containers cannot use .env files — API keys must come from AWS Secrets Manager. Adds secrets block to API and worker task definitions, grants execution role GetSecretValue permission, and documents the two manual create-secret commands needed before terraform apply. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0b00101111
reviewed
Mar 28, 2026
Contributor
0b00101111
left a comment
There was a problem hiding this comment.
Review
Good work — secrets injection is the right approach for ECS, IAM scoping is correct, and the manual step docs are clear.
Bug: env var names don't match app config
The secrets inject KIMI_API_KEY and GEMINI_API_KEY, but backend/app/config.py uses env_prefix="FLAIR2_", so the app reads FLAIR2_KIMI_API_KEY and FLAIR2_GEMINI_API_KEY.
As-is, the containers will start but both keys will be empty strings.
Fix in modules/ecs/main.tf (both API and worker task definitions):
secrets = [
{ name = "FLAIR2_KIMI_API_KEY", valueFrom = var.kimi_api_key_secret_arn },
{ name = "FLAIR2_GEMINI_API_KEY", valueFrom = var.gemini_api_key_secret_arn }
]Everything else looks good
- IAM policy scoped to
flair2/{env}/kimi-api-key*andflair2/{env}/gemini-api-key*— least privilege - Both API and worker tasks get the same secrets — correct
dev.tfvarshas clear instructions with exact CLI commands
Fix the env var names and this is ready to merge.
app/config.py uses env_prefix="FLAIR2_", so the container reads FLAIR2_KIMI_API_KEY and FLAIR2_GEMINI_API_KEY. The previous names (KIMI_API_KEY / GEMINI_API_KEY) would have injected empty strings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
Author
|
Fixed: renamed both secret env vars to use the
Both API and worker task definitions updated. Ready to merge. |
0b00101111
approved these changes
Mar 28, 2026
2 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
ECS containers cannot read
.envfiles — API keys must be injected at container startup via AWS Secrets Manager. Without this, containers would start but all Kimi/Gemini API calls would fail with missing key errors.Changes
modules/ecs/main.tf— addssecretsblock to both API and worker task definitions, injectingKIMI_API_KEYandGEMINI_API_KEYfrom Secrets Manager ARNsmodules/ecs/variables.tf— addskimi_api_key_secret_arnandgemini_api_key_secret_arnvariablesmodules/iam/main.tf— grants ECS execution rolesecretsmanager:GetSecretValueon the two secret ARNs (scoped toflair2/{env}/kimi-api-key*andflair2/{env}/gemini-api-key*)variables.tf— exposes the two ARN variables at root level with creation instructionsenvironments/dev.tfvars— adds placeholder ARN values with comments showing the exactaws secretsmanager create-secretcommands to runManual step required before
terraform applyThen paste the returned ARNs into
terraform/environments/dev.tfvars.Test plan
terraform validatepassesterraform planshows secrets injected into task definitionsKIMI_API_KEYandGEMINI_API_KEYpresent after deploy🤖 Generated with Claude Code