The error "Missing required parameter in input: 'interactive'" typically occurs due to AWS CLI version mismatches or incorrect parameter syntax. Here's how to fix it:
1. Verify AWS CLI Version
ECS Exec requires:
AWS CLI v1.21.18+ or v2.1.31+
Session Manager Plugin v1.2.245.0+
Check versions:
bash Copy code
aws --version
session-manager-plugin --version
Update AWS CLI v2:
bash Copy code
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
2. Correct Command Syntax
Use this exact syntax with --interactive flag (no value needed):
bash Copy code
aws ecs execute-command \
--region us-east-1 \
--cluster your-cluster \
--task 158d1c8083dd495cb04e266a5eEXAMPLE \
--container your-container-name \
--command "/bin/sh" \
--interactive
3. Alternative Format (For Older CLI Versions)
Use --interactive without any following value:
bash Copy code
# Remove any trailing values after --interactive
aws ecs execute-command ... --interactive
4. Validate Parameters
Ensure these prerequisites are met:
✅ Task has "enableExecuteCommand": true (check with aws ecs describe-tasks)
✅ IAM roles have required SSM permissions
✅ Container is in RUNNING state
✅ Network allows outbound HTTPS (port 443)
5. Debug Using SSM
Test SSM connectivity directly:
bash Copy code
aws ssm start-session \
--target ecs:your-cluster-name_task-id_container-runtime-id
(Get container runtime ID from aws ecs describe-tasks output)
6. Troubleshooting Steps
If still failing:
bash Copy code
# Enable CLI debug logging
export AWS_DEBUG=1
# Run with full parameters
aws ecs execute-command \
--region us-east-1 \
--cluster my-cluster \
--task $(aws ecs list-tasks --cluster my-cluster --query 'taskArns[0]' --output text) \
--container app \
--command "/bin/bash" \
--interactive
Common Fixes:
IAM Issues : Reattach AmazonSSMManagedInstanceCore policy to task role
Task Version : Redeploy tasks after enabling execute command
Region Mismatch : Ensure --region matches cluster region
Container Shell : Use /bin/sh if /bin/bash isn't available
⚠️ If using Windows containers, replace /bin/sh with cmd.exe and remove --interactive.
ECS Exec Troubleshooting Guide