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

Extend ssm command-executed waiter to wait for all instances targeted by a command #3269

Closed
2 tasks done
arianvp opened this issue Oct 1, 2024 · 2 comments
Closed
2 tasks done
Assignees
Labels
closed-for-staleness feature-request This issue requests a feature. p2 This is a standard priority issue response-requested Waiting on additional info and feedback. waiter

Comments

@arianvp
Copy link

arianvp commented Oct 1, 2024

Describe the feature

aws ssm wait command-executed --command-id $id

waits for the entire command to be executed on all instances it targets

(Maybe we should rename the original waiter to wait command-invocation-executed

Use Case

With #1744 we can wait for a command to be executed on a single instance; however the SSM API has evolved and it's possible to send a command to multiple targets at the same time:

aws ssm send-command --document-name my-doc --targets 'key=tag:Name,values=my-servers' --query 'Command.CommandID'

I want to wait for all of the instances with Name=my-servers

Proposed Solution

The waiter should watch ssm:ListCommands(CommandId=id) until Commands[0].Status=Success

Other Information

My current workaround:

       tries=24
          while true; do
            sleep 5
            if [ $tries -eq 0 ]; then
              echo "Command did not finish in time"
              exit 0
            fi
            status=$(aws ssm list-commands \
                --command-id ${{ steps.send-command.outputs.command_id }} \
                --query "Commands[0].Status" \
                --output text)
            
            # if pending or in progress, or cancelling
            if [ "$status" = "Pending" ] || [ "$status" = "InProgress" ] || [ "$status" = "Cancelling" ]; then
              tries=$((tries-1))
              continue
            fi
            break
          done

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

SDK version used

aws-cli/2.17.56

Environment details (OS name and version, etc.)

MacOS

@arianvp arianvp added feature-request This issue requests a feature. needs-triage This issue or PR still needs to be triaged. labels Oct 1, 2024
@tim-finnigan tim-finnigan self-assigned this Oct 2, 2024
@tim-finnigan
Copy link
Contributor

Thanks for the feature request. Waiter models are created and maintained upstream by service teams, as they are used across AWS SDKs. It looks like CommandExecuted has been the only SSM waiter for a while:

To what extent does your request overlap with #1744 / aws/aws-sdk#90 ? Here is the related PR that was written: https://github.com/boto/botocore/pull/1753/files. The SSM team is still tracking the request to add this waiter, but it hasn't been prioritized. I can try checking in with them regarding this.

But I don't think the request to update a waiter's name or polling logic would be considered because of the need to maintain backwards compatible behavior. If you can, please let me know specifically what model changes you are proposing and I can share that with the SSM team.

@tim-finnigan tim-finnigan added response-requested Waiting on additional info and feedback. waiter p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Oct 2, 2024
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness feature-request This issue requests a feature. p2 This is a standard priority issue response-requested Waiting on additional info and feedback. waiter
Projects
None yet
Development

No branches or pull requests

2 participants