Skip to content

Enable ECS Exec for python_backend and pybot - #200

Merged
irvingpop merged 1 commit into
mainfrom
irvingpop/ecs-exec
Nov 23, 2026
Merged

irvingpop merged 1 commit into
mainfrom
irvingpop/ecs-exec

Conversation

@irvingpop

Copy link
Copy Markdown
Member

Summary

  • Enable ECS Exec on python_backend_prod, python_backend_staging and pybot_prod (enable_execute_command = true).
  • Add a per-service task role (python_backend_${env}, pybot_${env}) with the ssmmessages actions and log write access. These tasks had no task role before.
  • Cluster execute_command_configuration: logging OVERRIDE to the existing ecslogs group. Exec session streams are named ecs-execute-command-*.

Access

Only principals with ecs:ExecuteCommand can open a session. Today that is the infrastructure IAM group (AmazonECS_FullAccess) and the admins. No CI principal (GitHubActions-ECR-Push, circleci, python-backend) has ecs or ssm permissions. IAM users and groups are not managed in this repo.

Already applied and verified

Applied locally (staging first, then prod). On each service the task rolled, with about 1 minute of outage (minimumHealthyPercent=0).

Service Task def print(1) via exec Health
python_backend_staging :19 1 200
python_backend_prod :31 1 200
pybot_prod :12 1 ALB target healthy
aws ecs execute-command --cluster operationcode-ecs-us-east-2 --task <TASK_ARN> \
  --container python_backend_prod --interactive \
  --command "python manage.py shell" --profile operationcode --region us-east-2

🤖 Generated with Claude Code

Set enable_execute_command on python_backend (prod, staging) and pybot
(prod) services. Add a per-service task role with ssmmessages permissions
and log access, and send exec session logs to the ecslogs group via the
cluster execute_command_configuration.

Applying this rolls all three services (new task definitions).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude of Duty review, run 45231806613: 1 inline finding(s). Model output from untrusted input. Check it before you act on it. The gate result is in the summary comment.

Comment thread terraform/ecs.tf
# ECS Exec session logs go to the shared ECS log group
cluster_configuration = {
execute_command_configuration = {
logging = "OVERRIDE"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

low security, confidence low, pass security

Exec session logs stored unencrypted in shared 7-day log group

Exec sessions on production containers (which hold injected secrets from Secrets Manager) are logged into the shared ecslogs group, with no KMS encryption configured for the exec channel or the log group. Session output could include secrets and is readable by anyone with access to that log group. Impact is limited because access requires existing ecs:ExecuteCommand or log-read permissions.

Model output from untrusted input. Check it before you act on it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not changing this in this PR:

  • CloudWatch Logs encrypts all log groups at rest by default (AWS-owned key), and the exec channel itself is TLS. A customer KMS key would add only key-policy-based access control.
  • The people who can read ecslogs are the infrastructure group and the admins. They can already read the same secrets from Secrets Manager and open exec sessions themselves, so a separate key does not narrow access.
  • Container stdout in this group can already include the same data.

If we later want exec audit logs with their own retention or a narrower reader set, a dedicated /ecs/exec-sessions group is a small follow-up.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

🟡 Clear to proceed: Claude of Duty logged 1 item to consider

Mission: Review the code. Protect the branch. Deploy the future.

Note

1 finding to consider. It does not block this PR.
Next step for the author: read the finding and fix what you agree with.

Severity Effect Where Finding Found by
🟡 Low Does not block terraform/ecs.tf:41 Exec session logs stored unencrypted in shared 7-day log group See the inline comment. Security (low)
File checks Review Security Supply chain Dependency review Coverage
✅ ok ✅ ran, 0 findings ✅ ran, 1 finding ✅ ran, 0 findings ✅ ok ✅ complete

Run 45231806613, attempt 1 for head 9f74c0f into main. The required workflow in the merge box is the result that counts.

Claude of Duty never approves a PR. A human reviewer gives the final approval.

📋 Full review record: reasons, checks, signals, finding details, model summaries, token usage

Reviewed snapshot

Head SHA Merge base SHA Base branch Run
9f74c0f53a4b38aaf769e99b2415a15cee15c3c9 a27c321ed552f3692a40e66da60d976e37c7d55b main 45231806613, attempt 1

Reasons the gate failed

None. No reason applies.

Checks (code, no model)

Check Result Detail
Hard blocks ✅ none
Coverage ✅ complete files in comparison 8, files collected 8, trees complete
Model view full estimate 25,460 tokens, limit 200,000 tokens, multiplier 1x
Dependency changes ✅ none
Dependency review job ✅ success

Signals (context only, never block)

None.

Dependency changes

None.

Finding details

Model output from untrusted input. Check it before you act on it. Verified means only that the quoted text is at that place. It does not mean the claim is true.

Blocking is decided by code from category and severity, never by the model. A finding in a blocking category blocks only at high or critical severity.

Pass Severity Category Confidence Citation Posted Model title
Security low security low ✅ checked inline Exec session logs stored unencrypted in shared 7-day log group

The Review pass completed and reported no findings.

The Supply chain pass completed and reported no findings.

Model summaries

Model output from untrusted input. Check it before you act on it. Verified means only that the quoted text is at that place. It does not mean the claim is true.

Pass Status Model Summary
Review ✅ ok claude-sonnet-5-5 This PR enables ECS Exec on python_backend and pybot services. It adds a per-service task role, a cluster exec logging configuration, and a logs_group_arn variable. I found no correctness bugs in the changed code. The IAM role names, variable wiring and module inputs are consistent across the modules.
Security ✅ ok claude-sonnet-5-5 The PR enables ECS Exec on three ECS services and adds per-service task roles with ssmmessages and log-write permissions, plus cluster exec logging to CloudWatch. The IAM policies are narrowly scoped and standard for ECS Exec. One residual concern is that exec sessions give shell access to containers holding production secrets, and OVERRIDE logging records session output without any encryption configuration.
Supply chain ✅ ok claude-sonnet-5-5 This PR enables ECS Exec on the python_backend (prod and staging) and pybot (prod) ECS services. It adds per-service task IAM roles that grant ssmmessages and CloudWatch Logs write access, and sets cluster-level exec logging to the existing ecslogs group. I found no obfuscation, encoded payloads, network calls, dependency changes, CI edits, or text aimed at an AI reviewer. The change widens operational access, since interactive shell access now exists inside production containers that hold application secrets. Who can use it depends on IAM policies outside this repo, which the PR body describes but the diff does not show. No supply-chain or malicious finding is warranted.

Token usage

Pass Input Output Cache write Cache read Attempts
Review 727 112 0 22317 1
Security 1053 359 0 22317 1
Supply chain 1245 236 22317 0 1
Total 3025 707 22317 44634 3

@irvingpop
irvingpop merged commit 71636d5 into main Nov 23, 2026
5 checks passed
@irvingpop
irvingpop deleted the irvingpop/ecs-exec branch November 23, 2026 17:54
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.

1 participant