Skip to content
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

ECS execute-command failed due to an internal error (aws/aws-cli/issues/6834) #8080

Closed
istvanfedak-nbcu opened this issue Aug 4, 2023 · 4 comments
Assignees
Labels
closed-for-staleness ecs-execute-command response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@istvanfedak-nbcu
Copy link

Describe the bug

Related issues:

Unable to run aws ecs execute-command.

Expected Behavior

Open an interactive shell with the container.

Current Behavior

An error occurred (TargetNotConnectedException) when calling the ExecuteCommand operation: The execute command failed due to an internal error. Try again later.

Reproduction Steps

  1. Make sure that your ECS task execution role has all the required configuration defined in: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html
  2. Run:
    aws ecs execute-command
    --cluster MyCluster
    --task arn:aws:ecs:us-east-1:123456789012:task/MyCluster/d789e94343414c25b9f6bd59eEXAMPLE
    --container MyContainer
    --interactive
    --command "/bin/sh"

Possible Solution

No response

Additional Information/Context

I was able to run aws ecs execute-command last week and it stopped working today.

  • Amazon ECS-optimized Amazon Linux 2 AMI used in ECS clusters: ami-0507dff4275d8dd6d

CLI version used

aws-cli/2.11.20 Python/3.11.3 Darwin/20.6.0 source/x86_64 prompt/off

Environment details (OS name and version, etc.)

MacOS v11.7.8

@istvanfedak-nbcu istvanfedak-nbcu added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 4, 2023
@istvanfedak-nbcu
Copy link
Author

istvanfedak-nbcu commented Aug 4, 2023

I tested the ECS containers that are running on AWS Fargate and they're not affected by this issue (I'm able to open a shell with them).

This is the SSM version of the Amazon ECS-optimized Amazon Linux 2 AMI used in ECS clusters (ami-0507dff4275d8dd6d):

Loaded plugins: priorities, update-motd, upgrade-helper
Installed Packages
Name        : amazon-ssm-agent
Arch        : x86_64
Version     : 3.1.1732.0
Release     : 1.amzn2
Size        : 90 M
Repo        : installed
From repo   : amzn2-core
Summary     : Manage EC2 Instances using SSM APIs
URL         : http://docs.aws.amazon.com/ssm/latest/APIReference/Welcome.html
License     : ASL 2.0
Description : This package provides Amazon SSM Agent for managing EC2 Instances using SSM APIs

@istvanfedak-nbcu
Copy link
Author

Workaround:

  1. Connect to EC2 instance via Session Manager.
  2. List out all the containers running in the EC2 instance: sudo docker ps.
  3. Run the following command to open up a shell with the desired container: sudo docker exec --interactive --tty <container-id-value> sh

@tim-finnigan tim-finnigan self-assigned this Aug 7, 2023
@tim-finnigan
Copy link
Contributor

Hi @istvanfedak-nbcu thanks for reaching out. Can you confirm that the permissions you are using have not changed recently? In this troubleshooting post for TargetNotConnectedException it notes:

You might get this error due to the following reasons:

  • The Amazon ECS task role doesn't have the required permissions to run the execute-command command.
  • The AWS Identity and Access Management (IAM) role or user that's running the command doesn't have the required permissions.

This may be a better issue to track in aws-containers/amazon-ecs-exec-checker#47 or the SSM agent repository (https://github.com/aws/amazon-ssm-agent/issues).

Have you tried updating to a newer version of the SSM Agent? Here are the release notes for reference: https://github.com/aws/amazon-ssm-agent/blob/mainline/RELEASENOTES.md

@tim-finnigan tim-finnigan added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. ecs-execute-command and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 7, 2023
@github-actions
Copy link

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness ecs-execute-command response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants