

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# Amazon SAM 模板元数据部分属性
<a name="serverless-sam-template-publishing-applications-metadata-properties"></a>

`AWS::ServerlessRepo::Application` 是元数据键，可用于指定要发布到 Amazon Serverless Application Repository的应用程序信息。

**注意**  
Amazon CloudFormation `AWS::ServerlessRepo::Application`元数据[密钥不支持内部函数](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html)。

## Properties
<a name="serverless-sam-template-publishing-applications-metadata-properties-table"></a>

此表提供有关 Amazon SAM 模板`Metadata`部分属性的信息。本节是 Amazon Serverless Application Repository 使用向发布应用程序所必需的 Amazon SAMCLI。


****  

| 属性 | Type | 必需 | 描述 | 
| --- | --- | --- | --- | 
| Name | 字符串 | TRUE |   应用程序的名称。 最小长度 = 1。最大长度 = 140。 模式：`"[a-zA-Z0-9\\-]+";`  | 
| Description | 字符串 | TRUE |  关于应用程序的描述。 最小长度 = 1。最大长度 = 256。  | 
| Author | 字符串 | TRUE |  发布应用程序的作者的姓名。 最小长度 = 1。最大长度 = 127。 模式：`"^[a-z0-9](([a-z0-9]\|-(?!-))*[a-z0-9])?$";`  | 
| SpdxLicenseId | 字符串 | FALSE | 有效的许可证标识符。要查看有效的许可证标识符列表，请参阅 Software Package Data Exchange (SPDX) 网站上的 [SPDX 许可证列表](https://spdx.org/licenses/)。 | 
| LicenseUrl | 字符串 | FALSE |  对本地许可文件的引用，或指向许可证文件的 Amazon S3 链接，其中该文件与您的应用程序的 spdxLicenseId 值相匹配。 未使用该`sam package`命令打包的 Amazon SAM 模板文件可以引用此属性的本地文件。但是，要使用 `sam publish` 命令发布应用程序，此属性必须是对 Amazon S3 存储桶的引用。 最大大小：5 MB。 您必须为此属性提供一个值，才能使您的应用程序变为公有的。请注意，在应用程序发布后，您无法更新此属性。因此，要向应用程序添加许可证，必须先将其删除，或者发布具有不同名称的新应用程序。  | 
| ReadmeUrl | 字符串 | FALSE |  对本地自述文件的引用或指向自述文件的 Amazon S3 链接，其中该文件包含对应用程序及其工作原理的更详细描述。 未使用该`sam package`命令打包的 Amazon SAM 模板文件可以引用此属性的本地文件。但是，要使用 `sam publish` 命令发布，此属性必须是对 Amazon S3 存储桶的引用。 最大大小：5 MB。  | 
| Labels | 字符串 | FALSE |  改善在搜索中发现应用程序的结果的标签。 最小长度 = 1。最大长度 = 127。最大标签数量：10。 模式：`"^[a-zA-Z0-9+\\-_:\\/@]+$";`  | 
| HomePageUrl | 字符串 | FALSE | 包含有关应用程序的更多信息的 URL，例如应用程序 GitHub 存储库的位置。 | 
| SemanticVersion | 字符串 | FALSE |  应用程序的语义版本。有关语义版本控制规范，请访问[语义版本控制](https://semver.org/)网站。 您必须为此属性提供一个值，才能使您的应用程序变为公有的。  | 
| SourceCodeUrl | 字符串 | FALSE | 指向应用程序源代码的公共存储库的链接。 | 

## 使用案例
<a name="serverless-sam-template-publishing-applications-metadata-properties-cases"></a>

本节列出了发布应用程序的用例，以及为该用例处理的 `Metadata` 属性。*未*针对给定用例列出的属性将被忽略。
+ **创建新应用程序**-如果中没有 Amazon Serverless Application Repository 与账户名称相匹配的应用程序，则会创建新的应用程序。
  + `Name`
  + `SpdxLicenseId`
  + `LicenseUrl`
  + `Description`
  + `Author`
  + `ReadmeUrl`
  + `Labels`
  + `HomePageUrl`
  + `SourceCodeUrl`
  + `SemanticVersion`
  +  Amazon SAM 模板的内容（例如，任何事件源、资源和 Lambda 函数代码）

   
+ **创建应用程序版本**-如果中已经存在 Amazon Serverless Application Repository 与账户名称相匹配的应用程序，*并且 SemanticVersion**正在*更改，则会创建应用程序版本。
  + `Description`
  + `Author`
  + `ReadmeUrl`
  + `Labels`
  + `HomePageUrl`
  + `SourceCodeUrl`
  + `SemanticVersion`
  +  Amazon SAM 模板的内容（例如，任何事件源、资源和 Lambda 函数代码）

   
+ **更新应用程序**-如果中已经存在 Amazon Serverless Application Repository 与账户名称相匹配的应用程序，*并且*该 SemanticVersion应用程序*没有*更改，则会更新应用程序。
  + `Description`
  + `Author`
  + `ReadmeUrl`
  + `Labels`
  + `HomePageUrl`

## 示例
<a name="serverless-sam-template-publishing-applications-metadata-properties-example"></a>

下面是 `Metadata` 部分的示例：

```
Metadata:
  AWS::ServerlessRepo::Application:
    Name: my-app
    Description: hello world
    Author: user1
    SpdxLicenseId: Apache-2.0
    LicenseUrl: LICENSE.txt
    ReadmeUrl: README.md
    Labels: ['tests']
    HomePageUrl: https://github.com/user1/my-app-project
    SemanticVersion: 0.0.1
    SourceCodeUrl: https://github.com/user1/my-app-project
```