-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Add SsmGetCommandInvocationOperator and enhance SSM components #56936
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
Add SsmGetCommandInvocationOperator and enhance SSM components #56936
Conversation
This operator allows users to retrieve the output and execution details from SSM commands, supporting both single instance and all instances scenarios. Features: - Retrieve stdout/stderr from SSM command executions - Support for specific instance or all instances - Structured output with execution metadata - Comprehensive error handling Includes unit tests, documentation updates, and system test integration.
…mode Fixed deferrable SSM commands failing due to missing region configuration: * Fix NoRegionError in SsmRunCommandOperator when using deferrable=True * Add region_name, verify, and botocore_config parameters to SsmRunCommandTrigger constructor * Update SsmRunCommandOperator to pass AWS connection parameters to trigger * Add unit tests for trigger serialization and parameter passing The SsmRunCommandOperator was failing in deferrable mode with 'NoRegionError: You must specify a region' because the trigger was not receiving AWS connection parameters from the operator. This change ensures all AWS configuration (region_name, verify, botocore_config) is properly passed to the trigger and maintains backward compatibility.
- Ensure consistent return format. - Update tests to match standardised output structure The operator now consistently returns the same structure regardless of whether instance_id is provided, making it easier to work with downstream tasks.
- Change SsmHook.list_command_invocations() to return raw AWS API response - Update return type from list[dict] to dict for consistency with other AWS hooks - Modify SsmGetCommandInvocationOperator to handle raw response format - Update all unit tests to expect standardized response format This aligns SSM hook with the established pattern used by EC2Hook, LambdaHook, and other AWS hooks that return raw boto3 responses rather than processed data."
…xception` per latest contribution guidelines
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
…on (as per latest community guidelines)
o-nikolas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! Overall it looks quite good. Some feedback:
I don't love the mixture of changes. It's better to make your PRs as tightly scoped as possible, if you spot other things to fix try to do them in a separate PR.
You have some tests failing that need looking into, static checks can be run on your development machine (automatically as well as pre-commit/pre-push hooks), see the docs here for how to run those.
providers/amazon/src/airflow/providers/amazon/aws/operators/ssm.py
Outdated
Show resolved
Hide resolved
- Break long lines in SsmRunCommandOperator and SsmGetCommandInvocationOperator - Split long method calls, dictionary configurations, and log messages - Ensure all lines comply with 79-character limit per PEP 8
Thank you for the kind words. Re: Mixture of changes: I understand, and I'll make sure all changes are in their own PR going forward. Please let me know if you want me to revert this commit, and move to a new PR, or I'll be granted exception this time. Thank you! |
It's all good this time, no need to move to a new PR. You still have some static checks failing though. Ruff would be automatically fixed for you on pre-commit/pre-push if you enable those :) |
ferruzzi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good.
…g. Thank you @ferruzzi for your guidance.
ferruzzi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for your work!
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
Thank you both for your leadership and guidance! |
…e#56936) Add SsmGetCommandInvocationOperator for retrieving SSM command output This operator allows users to retrieve the output and execution details from SSM commands, supporting both single instance and all instances scenarios. Features: - Retrieve stdout/stderr from SSM command executions - Support for specific instance or all instances - Structured output with execution metadata - Comprehensive error handling Includes unit tests, documentation updates, and system test integration. * Pass AWS connection parameters to SsmRunCommandTrigger in deferrable mode Fixed deferrable SSM commands failing due to missing region configuration: * Fix NoRegionError in SsmRunCommandOperator when using deferrable=True * Add region_name, verify, and botocore_config parameters to SsmRunCommandTrigger constructor * Update SsmRunCommandOperator to pass AWS connection parameters to trigger * Add unit tests for trigger serialization and parameter passing
Description
This PR adds a new
SsmGetCommandInvocationOperatorand enhances existing SSM components to provide better command output retrieval capabilities.Changes
New Features
Enhancements
get_command_invocation()andlist_command_invocations()methodsTesting
Documentation
Use Cases
This enhancement enables several important use cases:
Example Usage