

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

# AWS::Serverless::Application
<a name="sam-resource-application"></a>

將來自 [AWS Serverless Application Repository](https://serverlessrepo.aws.amazon.com/applications)或來自 Amazon S3 儲存貯體的無伺服器應用程式內嵌為巢狀應用程式。巢狀應用程式會部署為巢狀[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stack.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stack.html)資源，其中可包含多個其他資源，包括其他[AWS::Serverless::Application](#sam-resource-application)資源。

**注意**  
當您部署到 時 AWS CloudFormation， 會將您的 AWS SAM 資源 AWS SAM 轉換為 CloudFormation 資源。如需詳細資訊，請參閱[為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。

## 語法
<a name="sam-resource-application-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

### YAML
<a name="sam-resource-application-syntax.yaml"></a>

```
Type: AWS::Serverless::Application
Properties:
  [Location](#sam-application-location): String | ApplicationLocationObject
  [NotificationARNs](#sam-application-notificationarns): List
  [Parameters](#sam-application-parameters): Map
  [Tags](#sam-application-tags): Map
  [TimeoutInMinutes](#sam-application-timeoutinminutes): Integer
```

## Properties
<a name="sam-resource-application-properties"></a>

 `Location`   <a name="sam-application-location"></a>
巢狀應用程式的範本 URL、檔案路徑或位置物件。  
如果提供範本 URL，其必須遵循 [CloudFormation TemplateUrl 文件](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-templateurl)中指定的格式，並包含有效的 CloudFormation 或 SAM 範本。[ApplicationLocationObject](sam-property-application-applicationlocationobject.md) 可用來指定已發佈至 的應用程式[AWS Serverless Application Repository](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html)。  
如果提供本機檔案路徑，範本必須經過包含 `sam deploy`或 `sam package`命令的工作流程，才能正確轉換應用程式。  
*類型*：字串 \$1 [ApplicationLocationObject](sam-property-application-applicationlocationobject.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性類似於 `AWS::CloudFormation::Stack` 資源的 `[TemplateURL](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-templateurl)` 屬性。CloudFormation 版本不會採用 從 [ApplicationLocationObject](sam-property-application-applicationlocationobject.md)擷取應用程式 AWS Serverless Application Repository。

 `NotificationARNs`   <a name="sam-application-notificationarns"></a>
現有 Amazon SNS 主題的清單，其中會傳送堆疊事件的通知。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::CloudFormation::Stack` 資源的 `[NotificationARNs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-notificationarns)` 屬性。

 `Parameters`   <a name="sam-application-parameters"></a>
應用程式參數值。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::CloudFormation::Stack` 資源的 `[Parameters](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-parameters)` 屬性。

 `Tags`   <a name="sam-application-tags"></a>
指定要新增到此應用程式之標籤的映射 （字串到字串）。金鑰和值僅限於英數字元。金鑰長度可以是 1 到 127 個 Unicode 字元，且字首不可為 aws：。值長度可以是 1 到 255 個 Unicode 字元。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::CloudFormation::Stack` 資源的 `[Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-tags)` 屬性。SAM 中的標籤屬性包含 Key：Value 對；在 CloudFormation 中包含標籤物件清單。建立堆疊時，SAM 會自動將`lambda:createdBy:SAM`標籤新增至此應用程式。此外，如果此應用程式來自 AWS Serverless Application Repository，則 SAM 也會自動新增兩個標籤 `serverlessrepo:applicationId:ApplicationId`和 `serverlessrepo:semanticVersion:SemanticVersion`。

 `TimeoutInMinutes`   <a name="sam-application-timeoutinminutes"></a>
 CloudFormation 等待巢狀堆疊達到 `CREATE_COMPLETE` 狀態的時間長度，以分鐘為單位。預設值為無逾時。當 CloudFormation 偵測到巢狀堆疊已達到 `CREATE_COMPLETE` 狀態時，它會將巢狀堆疊資源標記為父堆疊`CREATE_COMPLETE`中，並繼續建立父堆疊。如果逾時期間在巢狀堆疊達到 之前過期`CREATE_COMPLETE`， 會將巢狀堆疊 CloudFormation 標記為失敗，並復原巢狀堆疊和父堆疊。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::CloudFormation::Stack` 資源的 `[TimeoutInMinutes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-timeoutinminutes)` 屬性。

## 傳回值
<a name="sam-resource-application-return-values"></a>

### Ref
<a name="sam-resource-application-return-values-ref"></a>

當將此資源的邏輯 ID 提供給`Ref`內部 函數時，它會傳回基礎`AWS::CloudFormation::Stack`資源的資源名稱。

如需使用 `Ref`函數的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)》中的 。

### Fn::GetAtt
<a name="sam-resource-application-return-values-fn--getatt"></a>

`Fn::GetAtt` 會傳回此類型之指定屬性的值。以下為可用屬性及傳回值的範例。

如需使用 的詳細資訊`Fn::GetAtt`，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html)》中的 。

`Outputs.ApplicationOutputName`  <a name="Outputs.ApplicationOutputName-fn::getatt"></a>
名稱為 的堆疊輸出值`ApplicationOutputName`。

## 範例
<a name="sam-resource-application--examples"></a>

### SAR 應用程式
<a name="sam-resource-application--examples--sar-application"></a>

使用 Serverless Application Repository 範本的應用程式

#### YAML
<a name="sam-resource-application--examples--sar-application--yaml"></a>

```
Type: AWS::Serverless::Application
Properties:
  Location:
    ApplicationId: 'arn:aws:serverlessrepo:us-east-1:012345678901:applications/my-application'
    SemanticVersion: 1.0.0
  Parameters:
    StringParameter: parameter-value
    IntegerParameter: 2
```

### 一般應用程式
<a name="sam-resource-application--examples--normal-application"></a>

S3 url 的應用程式

#### YAML
<a name="sam-resource-application--examples--normal-application--yaml"></a>

```
Type: AWS::Serverless::Application
Properties:
  Location: https://s3.amazonaws.com/sam-s3-demo-bucket/template.yaml
```

# ApplicationLocationObject
<a name="sam-property-application-applicationlocationobject"></a>

已發佈至 的應用程式[AWS Serverless Application Repository](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html)。

## 語法
<a name="sam-property-application-applicationlocationobject-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

### YAML
<a name="sam-property-application-applicationlocationobject-syntax.yaml"></a>

```
  [ApplicationId](#sam-application-applicationlocationobject-applicationid): String
  [SemanticVersion](#sam-application-applicationlocationobject-semanticversion): String
```

## Properties
<a name="sam-property-application-applicationlocationobject-properties"></a>

 `ApplicationId`   <a name="sam-application-applicationlocationobject-applicationid"></a>
應用程式的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `SemanticVersion`   <a name="sam-application-applicationlocationobject-semanticversion"></a>
應用程式的語義版本。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-application-applicationlocationobject--examples"></a>

### my-application
<a name="sam-property-application-applicationlocationobject--examples--my-application"></a>

應用程式位置物件範例

#### YAML
<a name="sam-property-application-applicationlocationobject--examples--my-application--yaml"></a>

```
Location:
  ApplicationId: 'arn:aws:serverlessrepo:us-east-1:012345678901:applications/my-application'
  SemanticVersion: 1.0.0
```