

# sam local execution
<a name="sam-cli-command-reference-sam-local-execution"></a>

This page provides reference information for the AWS Serverless Application Model Command Line Interface (AWS SAM CLI) `sam local execution` command.

For an introduction to the AWS SAM CLI, see [What is the AWS SAM CLI?](what-is-sam-overview.md#what-is-sam-cli)

The `sam local execution` command allows you to manage and inspect local durable function executions during development and testing.

**Note**  
These commands may not require access to AWS credentials.

## Usage
<a name="sam-cli-command-reference-sam-local-execution-usage"></a>

```
$ sam local execution <subcommand> <options>
```

## Options
<a name="sam-cli-command-reference-sam-local-execution-options"></a>

`--help, -h`  <a name="sam-cli-command-reference-sam-local-execution-options-help"></a>
Show this message and exit.

## Subcommands
<a name="sam-cli-command-reference-sam-local-execution-subcommands"></a>

`get`  <a name="sam-cli-command-reference-sam-local-execution-subcommands-get"></a>
Get details of a durable function execution. For more information, see [sam local execution get](sam-cli-command-reference-sam-local-execution-get.md).

`history`  <a name="sam-cli-command-reference-sam-local-execution-subcommands-history"></a>
Get execution history of a durable function execution. For more information, see [sam local execution history](sam-cli-command-reference-sam-local-execution-history.md).

`stop`  <a name="sam-cli-command-reference-sam-local-execution-subcommands-stop"></a>
Stop a durable function execution. For more information, see [sam local execution stop](sam-cli-command-reference-sam-local-execution-stop.md).

# sam local execution get
<a name="sam-cli-command-reference-sam-local-execution-get"></a>

Retrieve the details of a specific durable function execution.

**Note**  
This command may not require access to AWS credentials.

## Usage
<a name="ref-sam-cli-local-execution-get-usage"></a>

```
$ sam local execution get DURABLE_EXECUTION_ARN [OPTIONS]
```

## Required Arguments
<a name="ref-sam-cli-local-execution-get-arguments"></a>

`DURABLE_EXECUTION_ARN`  
The Amazon Resource Name (ARN) of the durable function execution to retrieve details for.

## Options
<a name="ref-sam-cli-local-execution-get-options"></a>

`--format [summary|json]`  
Output format. Default: `summary`

`--region TEXT`  
Set the AWS Region of the service (for example, `us-east-1`).

`--profile TEXT`  
Select a specific profile from your credential file to get AWS credentials.

`--config-env TEXT`  
Environment name specifying default parameter values in the configuration file. Default: `default`

`--config-file TEXT`  
Configuration file containing default parameter values. Default: `samconfig.toml`

`--save-params`  
Save the parameters provided via the command line to the configuration file.

`--beta-features / --no-beta-features`  
Enable/Disable beta features.

`--debug`  
Turn on debug logging to print debug messages generated by AWS SAM CLI and display timestamps.

`-h, --help`  
Shows this message and exits.

## Examples
<a name="ref-sam-cli-local-execution-get-examples"></a>

Get execution details with default summary format:

```
$ sam local execution get arn:aws:lambda:us-east-1:123456789012:function:MyFunction:$LATEST/durable-execution/my-execution-name/my-execution-id
```

Get execution details in JSON format:

```
$ sam local execution get arn:aws:lambda:us-east-1:123456789012:function:MyFunction:$LATEST/durable-execution/my-execution-name/my-execution-id --format json
```

# sam local execution history
<a name="sam-cli-command-reference-sam-local-execution-history"></a>

Get execution history of a durable function execution.

## Usage
<a name="ref-sam-cli-local-execution-history-usage"></a>

```
$ sam local execution history EXECUTION_ID [OPTIONS]
```

## Required Arguments
<a name="ref-sam-cli-local-execution-history-arguments"></a>

`EXECUTION_ID`  
The unique identifier of the durable function execution to retrieve history for.

## Options
<a name="ref-sam-cli-local-execution-history-options"></a>

`--format [table|json]`  
Output format. Default: `table`

`--region TEXT`  
Set the AWS Region of the service (for example, `us-east-1`).

`--profile TEXT`  
Select a specific profile from your credential file to get AWS credentials.

`--config-env TEXT`  
Environment name specifying default parameter values in the configuration file. Default: `default`

`--config-file TEXT`  
Configuration file containing default parameter values. Default: `samconfig.toml`

`--save-params`  
Save the parameters provided via the command line to the configuration file.

`--beta-features / --no-beta-features`  
Enable/Disable beta features.

`--debug`  
Turn on debug logging to print debug messages generated by AWS SAM CLI and display timestamps.

`-h, --help`  
Shows this message and exits.

## Examples
<a name="ref-sam-cli-local-execution-history-examples"></a>

Get execution history in table format:

```
$ sam local execution history my-execution-id
```

Get execution history in JSON format:

```
$ sam local execution history my-execution-id --format json
```

# sam local execution stop
<a name="sam-cli-command-reference-sam-local-execution-stop"></a>

Stop a running durable function execution.

**Note**  
This command may not require access to AWS credentials.

## Usage
<a name="ref-sam-cli-local-execution-stop-usage"></a>

```
$ sam local execution stop DURABLE_EXECUTION_ARN [OPTIONS]
```

## Required Arguments
<a name="ref-sam-cli-local-execution-stop-arguments"></a>

`DURABLE_EXECUTION_ARN`  
The Amazon Resource Name (ARN) of the durable function execution to stop.

## Options
<a name="ref-sam-cli-local-execution-stop-options"></a>

`--error-message TEXT`  
Error message to associate with the stopped execution.

`--error-type TEXT`  
Error type to associate with the stopped execution.

`--error-data TEXT`  
Error data to associate with the stopped execution.

`--stack-trace TEXT`  
Stack trace entries. This option can be specified multiple times.

`--region TEXT`  
Set the AWS Region of the service (for example, `us-east-1`).

`--profile TEXT`  
Select a specific profile from your credential file to get AWS credentials.

`--config-env TEXT`  
Environment name specifying default parameter values in the configuration file. Default: `default`

`--config-file TEXT`  
Configuration file containing default parameter values. Default: `samconfig.toml`

`--save-params`  
Save the parameters provided via the command line to the configuration file.

`--beta-features / --no-beta-features`  
Enable/Disable beta features.

`--debug`  
Turn on debug logging to print debug messages generated by AWS SAM CLI and display timestamps.

`-h, --help`  
Shows this message and exits.

## Examples
<a name="ref-sam-cli-local-execution-stop-examples"></a>

Stop execution without error details:

```
$ sam local execution stop arn:aws:lambda:us-east-1:123456789012:function:MyFunction:$LATEST/durable-execution/my-execution-name/my-execution-id
```

Stop execution with error message and type:

```
$ sam local execution stop arn:aws:lambda:us-east-1:123456789012:function:MyFunction:$LATEST/durable-execution/my-execution-name/my-execution-id --error-message "Execution cancelled" --error-type "UserCancellation"
```

Stop execution with full error details and stack trace:

```
$ sam local execution stop arn:aws:lambda:us-east-1:123456789012:function:MyFunction:$LATEST/durable-execution/my-execution-name/my-execution-id --error-message "Task failed" --error-type "TaskFailure" --error-data '{"reason":"timeout"}' --stack-trace "at function1()" --stack-trace "at function2()"
```