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, fail_on_nonzero_exit=True, 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)

  • fail_on_nonzero_exit (bool) – If True (default), the operator will fail when the command returns a non-zero exit code. If False, the operator will complete successfully regardless of the command exit code, allowing downstream tasks to handle exit codes for workflow routing. Note that AWS-level failures (Cancelled, TimedOut) will still raise exceptions even when this is False. (default: True)

  • 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]
fail_on_nonzero_exit = True[source]
deferrable[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.

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?