

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

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

此頁面提供 AWS Serverless Application Model Command Line Interface (AWS SAM CLI) `sam list`命令的參考資訊。

如需 的簡介 AWS SAM CLI，請參閱 [什麼是 AWS SAM CLI？](what-is-sam-overview.md#what-is-sam-cli)

`sam list` 命令會輸出有關無伺服器應用程式中資源和無伺服器應用程式狀態的重要資訊。在部署**sam list**前後使用 在本機和雲端開發期間提供協助。

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

```
$ sam list <options> <subcommand>
```

## 選項
<a name="sam-cli-command-reference-sam-list-options"></a>

`--help, -h`  <a name="sam-cli-command-reference-sam-list-options-help"></a>
顯示此訊息並結束。

## 子命令
<a name="sam-cli-command-reference-sam-list-subcommands"></a>

`endpoints`  <a name="sam-cli-command-reference-sam-list-subcommands-endpoints"></a>
顯示 CloudFormation 堆疊中的雲端和本機端點清單。如需詳細資訊，請參閱[sam list endpoints](sam-cli-command-reference-sam-list-endpoints.md)。

`resources`  <a name="sam-cli-command-reference-sam-list-subcommands-resources"></a>
顯示部署 AWS CloudFormation 時在 中建立的 AWS Serverless Application Model (AWS SAM) 範本中的資源。如需詳細資訊，請參閱[sam list resources](sam-cli-command-reference-sam-list-resources.md)。

`stack-outputs`  <a name="sam-cli-command-reference-sam-list-subcommands-stack-outputs"></a>
顯示來自 AWS SAM 或 CloudFormation 範本的 CloudFormation 堆疊輸出。如需詳細資訊，請參閱[sam list stack-outputs](sam-cli-command-reference-sam-list-stack-outputs.md)。

# sam list endpoints
<a name="sam-cli-command-reference-sam-list-endpoints"></a>

此頁面提供 AWS Serverless Application Model 命令列界面 (AWS SAM CLI) `sam list endpoints`子命令的參考資訊。

如需 的簡介 AWS SAM CLI，請參閱 [什麼是 AWS SAM CLI？](what-is-sam-overview.md#what-is-sam-cli)

`sam list endpoints` 子命令會顯示您 CloudFormation 堆疊中的雲端和本機端點清單。您可以透過 **sam local**和 **sam sync**命令與這些資源互動。

AWS Lambda 此命令支援 和 Amazon API Gateway 資源類型。

**注意**  
為您的 Amazon API Gateway 資源設定時，支援自訂網域。此命令將輸出自訂網域，而不是預設端點。

## Usage
<a name="sam-cli-command-reference-sam-list-endpoints-usage"></a>

```
$ sam list endpoints <options>
```

## 選項
<a name="sam-cli-command-reference-sam-list-endpoints-options"></a>

`--config-env TEXT`  <a name="sam-cli-command-reference-sam-list-endpoints-options-config-env"></a>
在要使用的組態檔案中指定預設參數值的環境名稱。  
*預設值*：`default`  
如需關於組態檔案的詳細資訊，請參閱 [AWS SAM CLI 組態檔案](serverless-sam-cli-config.md)。

`--config-file TEXT`  <a name="sam-cli-command-reference-sam-list-endpoints-options-config-file"></a>
組態檔案的路徑和檔案名稱，其中包含要使用的預設參數值。  
*預設值*：`samconfig.toml`在目前的工作目錄中。  
如需關於組態檔案的詳細資訊，請參閱 [AWS SAM CLI 組態檔案](serverless-sam-cli-config.md)。

`--debug`  <a name="sam-cli-command-reference-sam-list-endpoints-options-debug"></a>
開啟偵錯記錄，以列印由具有時間戳記的 AWS SAM CLI產生的偵錯訊息。

`--help, -h`  <a name="sam-cli-command-reference-sam-list-endpoints-options-help"></a>
顯示此訊息並結束。

`--output [json|table]`  <a name="sam-cli-command-reference-sam-list-endpoints-options-output"></a>
指定輸出結果的格式。  
*預設值*：`table`

`--profile TEXT`  <a name="sam-cli-command-reference-sam-list-endpoints-options-profile"></a>
從登入資料檔案選取特定設定檔以取得 AWS 登入資料。

`--region TEXT`  <a name="sam-cli-command-reference-sam-list-endpoints-options-region"></a>
設定服務 AWS 的區域。例如 `us-east-1`。

`--save-params`  <a name="sam-cli-command-reference-sam-list-endpoints-options-save-params"></a>
將您在命令列提供的參數儲存至 AWS SAM 組態檔案。

`--stack-name TEXT`  <a name="sam-cli-command-reference-sam-list-endpoints-options-stack-name"></a>
部署堆疊的名稱 CloudFormation 。您可以在應用程式的 `samconfig.toml` 檔案或指定的組態檔案中找到堆疊名稱。  
未指定此選項時，會顯示範本中定義的本機資源。

`--template-file, --template, -t PATH`  <a name="sam-cli-command-reference-sam-list-endpoints-options-template"></a>
AWS SAM 範本檔案。  
*預設值*：`template.[yaml|yml|json]`

## 範例
<a name="sam-cli-command-reference-sam-list-endpoints-examples"></a>

從名為 的 CloudFormation 堆疊中，以 json 格式顯示已部署資源端點的輸出`test-stack`。

```
$ sam list endpoints --stack-name test-stack --output json
			
[
  {
    "LogicalResourceId": "HelloWorldFunction",
    "PhysicalResourceId": "sam-app-test-list-HelloWorldFunction-H85Y7yIV7ZLq",
    "CloudEndpoint": "https://zt55oi7kbljxjmcoahsj3cknwu0rposq.lambda-url.us-east-1.on.aws/",
    "Methods": "-"
  },
  {
    "LogicalResourceId": "ServerlessRestApi",
    "PhysicalResourceId": "uj80uoe2o2",
    "CloudEndpoint": [
      "https://uj80uoe2o2.execute-api.us-east-1.amazonaws.com/Prod",
      "https://uj80uoe2o2.execute-api.us-east-1.amazonaws.com/Stage"
    ],
    "Methods": [
      "/hello['get']"
    ]
  }
]
```

# sam list resources
<a name="sam-cli-command-reference-sam-list-resources"></a>

此頁面提供 AWS Serverless Application Model 命令列界面 (AWS SAM CLI) `sam list resources`子命令的參考資訊。

如需 的簡介 AWS SAM CLI，請參閱 [什麼是 AWS SAM CLI？](what-is-sam-overview.md#what-is-sam-cli)

`sam list resources` 子命令會顯示部署時轉換 AWS CloudFormation 在 AWS SAM 中建立的 AWS Serverless Application Model (AWS SAM) 範本中的資源。

在部署之前**sam list resources**搭配 AWS SAM 範本使用 ，以查看要建立的資源。提供 CloudFormation 堆疊名稱以檢視包含已部署資源的合併清單。

**注意**  
若要從 AWS SAM 範本產生資源清單，會執行範本的本機轉換。此清單中包含將隨條件部署的資源，例如特定區域內的資源。

## Usage
<a name="sam-cli-command-reference-sam-list-resources-usage"></a>

```
$ sam list resources <options>
```

## 選項
<a name="sam-cli-command-reference-sam-list-resources-options"></a>

`--config-env TEXT`  <a name="sam-cli-command-reference-sam-list-resources-options-config-env"></a>
在要使用的組態檔案中指定預設參數值的環境名稱。  
*預設值*：`default`  
如需關於組態檔案的詳細資訊，請參閱 [AWS SAM CLI 組態檔案](serverless-sam-cli-config.md)。

`--config-file TEXT`  <a name="sam-cli-command-reference-sam-list-resources-options-config-file"></a>
組態檔案的路徑和檔案名稱，其中包含要使用的預設參數值。  
*預設值*：`samconfig.toml`在目前的工作目錄中。  
如需關於組態檔案的詳細資訊，請參閱 [AWS SAM CLI 組態檔案](serverless-sam-cli-config.md)。

`--debug`  <a name="sam-cli-command-reference-sam-list-resources-options-debug"></a>
開啟偵錯記錄，以列印由具有時間戳記的 AWS SAM CLI產生的偵錯訊息。

`--help, -h`  <a name="sam-cli-command-reference-sam-list-resources-options-help"></a>
顯示此訊息並結束。

`--output [json|table]`  <a name="sam-cli-command-reference-sam-list-resources-options-output"></a>
指定輸出結果的格式。  
*預設值*：`table`

`--profile TEXT`  <a name="sam-cli-command-reference-sam-list-resources-options-profile"></a>
從登入資料檔案選取特定設定檔以取得 AWS 登入資料。

`--region TEXT`  <a name="sam-cli-command-reference-sam-list-resources-options-region"></a>
設定服務 AWS 的區域。例如 `us-east-1`。

`--save-params`  <a name="sam-cli-command-reference-sam-list-resources-options-save-params"></a>
將您在命令列提供的參數儲存至 AWS SAM 組態檔案。

`--stack-name TEXT`  <a name="sam-cli-command-reference-sam-list-resources-options-stack-name"></a>
部署堆疊的名稱 CloudFormation 。您可以在應用程式的 `samconfig.toml` 檔案或指定的組態檔案中找到堆疊名稱。  
提供時，範本中的資源邏輯 IDs 將映射至其對應的實體 IDs CloudFormation。若要進一步了解實體 IDs，請參閱*AWS CloudFormation 《 使用者指南*》中的[資源欄位](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html#resources-section-structure-resource-fields)。  
未指定此選項時，會顯示範本中定義的本機資源。

`--template-file, --template, -t PATH`  <a name="sam-cli-command-reference-sam-list-resources-options-"></a>
AWS SAM 範本檔案。  
*預設值*：`template.[yaml|yml|json]`

## 範例
<a name="sam-cli-command-reference-sam-list-resources-examples"></a>

以資料表格式顯示 AWS SAM 範本中本機資源的輸出，以及從名為 的 CloudFormation 堆疊中部署的資源`test-stack`。從與本機範本相同的目錄執行 。

```
$ sam list resources --stack-name test-stack --output table
			
-------------------------------------------------------------------------------------------------------------------------
Logical ID                                                   Physical ID
-------------------------------------------------------------------------------------------------------------------------
HelloWorldFunction                                           sam-app-test-list-HelloWorldFunction-H85Y7yIV7ZLq
HelloWorldFunctionHelloWorldPermissionProd                   sam-app-test-list-
                                                             HelloWorldFunctionHelloWorldPermissionProd-1QH7CPOCBL2IK
HelloWorldFunctionRole                                       sam-app-test-list-HelloWorldFunctionRole-SRJDMJ6F7F41
ServerlessRestApi                                            uj80uoe2o2
ServerlessRestApiDeployment47fc2d5f9d                        pncw5f
ServerlessRestApiProdStage                                   Prod
ServerlessRestApiDeploymentf5716dc08b                        -
-------------------------------------------------------------------------------------------------------------------------
```

# sam list stack-outputs
<a name="sam-cli-command-reference-sam-list-stack-outputs"></a>

此頁面提供 AWS Serverless Application Model 命令列界面 (AWS SAM CLI) `sam list stack-outputs`子命令的參考資訊。

如需 的簡介 AWS SAM CLI，請參閱 [什麼是 AWS SAM CLI？](what-is-sam-overview.md#what-is-sam-cli)

`sam list stack-outputs` 子命令會顯示來自 AWS Serverless Application Model (AWS SAM) 或 CloudFormation 範本的 AWS CloudFormation 堆疊輸出。如需 的詳細資訊`Outputs`，請參閱*AWS CloudFormation 《 使用者指南*》中的[輸出](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html)。

## Usage
<a name="sam-cli-command-reference-sam-list-stack-outputs-usage"></a>

```
$ sam list stack-outputs <options>
```

## 選項
<a name="sam-cli-command-reference-sam-list-stack-outputs-options"></a>

`--config-env TEXT`  <a name="sam-cli-command-reference-sam-list-stack-outputs-options-config-env"></a>
在要使用的組態檔案中指定預設參數值的環境名稱。  
*預設值*：`default`  
如需關於組態檔案的詳細資訊，請參閱 [AWS SAM CLI 組態檔案](serverless-sam-cli-config.md)。

`--config-file TEXT`  <a name="sam-cli-command-reference-sam-list-stack-outputs-options-config-file"></a>
組態檔案的路徑和檔案名稱，其中包含要使用的預設參數值。  
*預設值*：`samconfig.toml`在目前的工作目錄中。  
如需關於組態檔案的詳細資訊，請參閱 [AWS SAM CLI 組態檔案](serverless-sam-cli-config.md)。

`--debug`  <a name="sam-cli-command-reference-sam-list-stack-outputs-options-debug"></a>
開啟偵錯記錄，以列印由具有時間戳記的 AWS SAM CLI產生的偵錯訊息。

`--help, -h`  <a name="sam-cli-command-reference-sam-list-stack-outputs-options-help"></a>
顯示此訊息並結束。

`--output [json|table]`  <a name="sam-cli-command-reference-sam-list-stack-outputs-options-output"></a>
指定輸出結果的格式。  
*預設值*：`table`

`--profile TEXT`  <a name="sam-cli-command-reference-sam-list-stack-outputs-options-profile"></a>
從登入資料檔案選取特定設定檔以取得 AWS 登入資料。

`--region TEXT`  <a name="sam-cli-command-reference-sam-list-stack-outputs-options-region"></a>
設定服務 AWS 的區域。例如 `us-east-1`。

`--save-params`  <a name="sam-cli-command-reference-sam-list-stack-outputs-options-save-params"></a>
將您在命令列提供的參數儲存至 AWS SAM 組態檔案。

`--stack-name TEXT`  <a name="sam-cli-command-reference-sam-list-stack-outputs-options-"></a>
部署堆疊的名稱 CloudFormation 。您可以在應用程式的 `samconfig.toml` 檔案或指定的組態檔案中找到堆疊名稱。  
此選項為必要。

## 範例
<a name="sam-cli-command-reference-sam-list-stack-outputs-examples"></a>

以資料表格式顯示 CloudFormation 堆疊中名為 之資源的輸出`test-stack`。

```
$ sam list stack-outputs --stack-name test-stack --output table
			
------------------------------------------------------------------------------------------------------------------------
OutputKey                                OutputValue                              Description
------------------------------------------------------------------------------------------------------------------------
HelloWorldFunctionIamRole                arn:aws:iam::account-number:role/sam-      Implicit IAM Role created for Hello
                                         app-test-list-HelloWorldFunctionRole-    World function
                                         SRJDMJ6F7F41
HelloWorldApi                            https://uj80uoe2o2.execute-api.us-       API Gateway endpoint URL for Prod
                                         east-1.amazonaws.com/Prod/hello/         stage for Hello World function
HelloWorldFunction                       arn:aws:lambda:us-                       Hello World Lambda Function ARN
                                         east-1:account-number:function:sam-app-
                                         test-list-
                                         HelloWorldFunction-H85Y7yIV7ZLq
------------------------------------------------------------------------------------------------------------------------
```