ksharlandjiev opened a new pull request, #56936:
URL: https://github.com/apache/airflow/pull/56936
## Description
This PR adds a new `SsmGetCommandInvocationOperator` and enhances existing
SSM components to provide better command output retrieval capabilities.
## Changes
### New Features
- **SsmGetCommandInvocationOperator**: New operator to retrieve output and
execution details from SSM command invocations
- Supports retrieving output from specific instances or all instances
- Returns structured data with stdout, stderr, execution times, and status
- Handles errors gracefully with proper logging
### Enhancements
- **SsmHook**: Added `get_command_invocation()` and
`list_command_invocations()` methods
- **SsmRunCommandOperator**: Enhanced deferrable mode with proper AWS
parameter passing to triggers
- **SsmRunCommandTrigger**: Improved async execution and AWS connection
parameter handling
### Testing
- Added unit tests for all new functionality
- Updated the system test demonstrating end-to-end usage
### Documentation
- Updated RST documentation with usage examples
## Use Cases
This enhancement enables several important use cases:
1. **Command Output Retrieval**: Get stdout/stderr from SSM commands for
downstream processing
2. **Debugging**: Inspect command execution details for troubleshooting
3. **Data Processing**: Use SSM command output as input for subsequent tasks
4. **Monitoring**: Track command execution status and performance metrics
## Example Usage
```python
# Run a command
run_command = SsmRunCommandOperator(
task_id="run_command",
document_name="AWS-RunShellScript",
run_command_kwargs={
"InstanceIds": ["i-1234567890abcdef0"],
"Parameters": {"commands": ["echo 'Hello World'"]}
}
)
# Get the output
get_output = SsmGetCommandInvocationOperator(
task_id="get_output",
command_id="{{ ti.xcom_pull(task_ids='run_command') }}",
instance_id="i-1234567890abcdef0"
)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]