

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

# 应用程序功能：IAM 角色、资源策略和嵌套应用程序
<a name="acknowledging-application-capabilities"></a>

在部署应用程序之前， AWS Serverless Application Repository 会检查应用程序模板中是否有 IAM 角色、 AWS 资源策略以及模板指定应创建的嵌套应用程序。IAM 资源，例如具有完全访问权限的 IAM 角色，可以修改您 AWS 账户中的任何资源。因此，建议您在继续之前检查与应用程序关联的权限，以便您不会无意中创建具有升级权限的资源。为确保已完成此操作，您必须先确认该应用程序包含功能，然后 AWS Serverless Application Repository 才能代表您部署应用程序。

应用程序可能包含以下四个功能中的任何功能：`CAPABILITY_IAM`、`CAPABILITY_NAMED_IAM`、`CAPABILITY_RESOURCE_POLICY` 和 `CAPABILITY_AUTO_EXPAND`。

以下资源需要您指定`CAPABILITY_IAM`或`CAPABILITY_NAMED_IAM`：[AWS::IAM::Group](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-group.html)、[AWS::IAM::InstanceProfile[AWS::IAM::Policy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-policy.html)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-instanceprofile.html)、和[AWS::IAM::Role](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html)。如果应用程序包含具有自定义名称的 IAM 资源，您必须指定 `CAPABILITY_NAMED_IAM`。有关如何指定功能的示例，请参阅[查找并确认应用程序功能 (AWS CLI)](serverlessrepo-how-to-consume.md#acknowledging-application-capabilities-api)。

以下资源需要您指定`CAPABILITY_RESOURCE_POLICY`：[AWS::Lambda::LayerVersion权限](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversionpermission.html)、、[AWS::Events::EventBus策略[AWS::Lambda::Permission](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-permission.html)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-eventbuspolicy.html)、[AWS:: iam: Policy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-policy.html)、、、[AWS::ApplicationAutoScaling::ScalingPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-applicationautoscaling-scalingpolicy.html)、[AWS::S3::BucketPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-policy.html)和。[AWS::SQS::QueuePolicy[AWS::SNS::TopicPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-policy.html)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-policy.html)

包含一个或多个嵌套应用程序的应用程序要求您指定 `CAPABILITY_AUTO_EXPAND`。有关嵌套应用程序的更多信息，请参阅《*AWS Serverless Application Model 开发人员指南》*中的[嵌套应用程序](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-nested-applications.html)。

## 查找并确认应用程序功能（控制台）
<a name="acknowledging-application-capabilities-console"></a>

您可以在[AWS Serverless Application Repository 网站上](https://aws.amazon.com/serverless/serverlessrepo/)找到可用的应用程序，也可以通过 [Lambda 控制台（在 AWS Serverless Application Repository 选项卡下的 “**创建函数**” 页面上）](https://console.aws.amazon.com/lambda/home?region=us-east-1#/create?tab=serverlessApps)找到可用的应用程序。 AWS Serverless Application Repository 

默认情况下，要求确认用于创建自定义 IAM 角色或资源策略的功能的应用程序不会显示在搜索结果中。要搜索包含这些功能的应用程序，您必须选中 **Show apps that create custom IAM roles or resource policies (显示创建自定义 IAM 角色或资源策略的应用程序)** 复选框。

在您选择应用程序时，可以在 **Permissions (权限)** 选项卡下查看应用程序的功能。要部署应用程序，您需要选中 **I acknowledge this application creates custom IAM roles or resource policies (我确认此应用程序创建自定义 IAM 角色或资源策略)** 复选框。如果您不确认这些功能，则会看到以下错误消息：**需要确认。要进行部署，请选中配置应用程序参数部分中的复选框**。

## 查看应用程序功能 (AWS CLI)
<a name="acknowledging-application-capabilities-cli"></a>

要使用查看应用程序的功能 AWS CLI，您首先需要该应用程序的 Amazon 资源名称 (ARN)。然后，您可以执行以下命令：

```
aws serverlessrepo get-application \
--application-id application-arn
```

[requiredCapabilities](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/applications-applicationid.html#applications-applicationid-prop-version-requiredcapabilities) 响应属性包含您需要确认然后才能部署应用程序的应用程序功能列表。请注意，如果 [requiredCapabilities](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/applications-applicationid.html#applications-applicationid-prop-version-requiredcapabilities) 属性为空，则应用程序没有所需功能。

