airflow.providers.amazon.aws.hooks.ssm

Classes

SsmHook

Interact with Amazon Systems Manager (SSM).

Module Contents

class airflow.providers.amazon.aws.hooks.ssm.SsmHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook

Interact with Amazon Systems Manager (SSM).

Provide thin wrapper around boto3.client("ssm").

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

get_parameter_value(parameter, default=NOTSET)[source]

Return the provided Parameter or an optional default.

If it is encrypted, then decrypt and mask.

Parameters:
  • parameter (str) – The SSM Parameter name to return the value for.

  • default (str | airflow.providers.amazon.version_compat.ArgNotSet) – Optional default value to return if none is found.

get_command_invocation(command_id, instance_id)[source]

Get the output of a command invocation for a specific instance.

Parameters:
  • command_id (str) – The ID of the command.

  • instance_id (str) – The ID of the instance.

Returns:

The command invocation details including output.

Return type:

dict

list_command_invocations(command_id)[source]

List all command invocations for a given command ID.

Parameters:

command_id (str) – The ID of the command.

Returns:

Response from SSM list_command_invocations API.

Return type:

dict

static is_aws_level_failure(status)[source]

Check if a command status represents an AWS-level failure.

AWS-level failures are service-level issues that should always raise exceptions, as opposed to command-level failures (non-zero exit codes) which may be tolerated depending on the fail_on_nonzero_exit parameter.

According to AWS SSM documentation, the possible statuses are: Pending, InProgress, Delayed, Success, Cancelled, TimedOut, Failed, Cancelling

AWS-level failures are: - Cancelled: Command was cancelled before completion - TimedOut: Command exceeded the timeout period - Cancelling: Command is in the process of being cancelled

Parameters:

status (str) – The command invocation status from SSM.

Returns:

True if the status represents an AWS-level failure, False otherwise.

Return type:

bool

Was this entry helpful?