Complete the airflow survey & get a free airflow 3 certification!

airflow.providers.amazon.aws.operators.ssm

Classes

SsmRunCommandOperator

Executes the SSM Run Command to perform actions on managed instances.

SsmGetCommandInvocationOperator

Retrieves the output and execution details of an SSM command invocation.

Module Contents

class airflow.providers.amazon.aws.operators.ssm.SsmRunCommandOperator(*, document_name, run_command_kwargs=None, wait_for_completion=True, waiter_delay=120, waiter_max_attempts=75, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), **kwargs)[source]

Bases: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.ssm.SsmHook]

Executes the SSM Run Command to perform actions on managed instances.

See also

For more information on how to use this operator, take a look at the guide: Runs commands on one or more managed nodes

Parameters:
  • document_name (str) – The name of the Amazon Web Services Systems Manager document (SSM document) to run.

  • run_command_kwargs (dict[str, Any] | None) – Optional parameters to pass to the send_command API.

  • wait_for_completion (bool) – Whether to wait for cluster to stop. (default: True)

  • waiter_delay (int) – Time in seconds to wait between status checks. (default: 120)

  • waiter_max_attempts (int) – Maximum number of attempts to check for job completion. (default: 75)

  • deferrable (bool) – If True, the operator will wait asynchronously for the cluster to stop. This implies waiting for completion. This mode requires aiobotocore module to be installed. (default: False)

  • aws_conn_id – The Airflow connection used for AWS credentials. If this is None or empty then the default boto3 behaviour is used. If running Airflow in a distributed manner and aws_conn_id is None or empty, then default boto3 configuration would be used (and must be maintained on each worker node).

  • region_name – AWS region_name. If not specified then the default boto3 behaviour is used.

  • verify – Whether or not to verify SSL certificates. See: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • botocore_config – Configuration dictionary (key-values) for botocore client. See: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
wait_for_completion = True[source]
waiter_delay = 120[source]
waiter_max_attempts = 75[source]
deferrable = True[source]
document_name[source]
run_command_kwargs[source]
execute_complete(context, event=None)[source]
execute(context)[source]

Derive when creating an operator.

The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.amazon.aws.operators.ssm.SsmGetCommandInvocationOperator(*, command_id, instance_id=None, **kwargs)[source]

Bases: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.ssm.SsmHook]

Retrieves the output and execution details of an SSM command invocation.

This operator allows you to fetch the standard output, standard error, execution status, and other details from SSM commands. It can be used to retrieve output from commands executed by SsmRunCommandOperator in previous tasks, or from commands executed outside of Airflow entirely.

The operator returns structured data including stdout, stderr, execution times, and status information for each instance that executed the command.

See also

For more information on how to use this operator, take a look at the guide: Retrieve output from an SSM command invocation

Parameters:
  • command_id (str) – The ID of the SSM command to retrieve output for.

  • instance_id (str | None) – The ID of the specific instance to retrieve output for. If not provided, retrieves output from all instances that executed the command.

  • aws_conn_id – The Airflow connection used for AWS credentials. If this is None or empty then the default boto3 behaviour is used. If running Airflow in a distributed manner and aws_conn_id is None or empty, then default boto3 configuration would be used (and must be maintained on each worker node).

  • region_name – AWS region_name. If not specified then the default boto3 behaviour is used.

  • verify – Whether or not to verify SSL certificates. See: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • botocore_config – Configuration dictionary (key-values) for botocore client. See: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
command_id[source]
instance_id = None[source]
execute(context)[source]

Execute the operator to retrieve command invocation output.

Was this entry helpful?