

AWS App Runner 从 2026 年 4 月 30 日起，将不再向新客户开放。如果您想使用 App Runner，请在该日期之前注册。现有客户可以继续正常使用该服务。有关更多信息，请参阅 [AWS App Runner 可用性变更](https://docs.aws.amazon.com/apprunner/latest/dg/apprunner-availability-change.html)。

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

# App Runner API
<a name="api"></a>

 AWS App Runner 应用程序编程接口 (API) 是一种用于向 App Runner 服务发出请求的 RESTful API。您可以使用 API 来创建、列出、描述、更新和删除您中的 App Runner 资源 AWS 账户。

您可以直接在应用程序代码中调用 API，也可以使用其中一个 AWS SDKs。

如需完整的 API 参考信息，请参阅 [AWS App Runner API 参考](https://docs.aws.amazon.com/apprunner/latest/api/)。

有关 AWS 开发者工具的更多信息，请参阅[构建工具 AWS](https://aws.amazon.com/tools/)。

**Topics**
+ [使用与 App Runner 配合使用 AWS CLI](#api.cli)
+ [使用 AWS CloudShell 来使用 AWS App Runner](api-cshell.md)

## 使用与 App Runner 配合使用 AWS CLI
<a name="api.cli"></a>

对于命令行脚本，[AWS CLI](https://docs.aws.amazon.com/cli/)请使用调用 App Runner 服务。*有关完整的 AWS CLI 参考信息，请参阅《命令参考》中的 [apprunner](https://docs.aws.amazon.com/cli/latest/reference/apprunner/)。AWS CLI *

AWS CloudShell 允许您跳过在开发环境 AWS CLI 中安装的步骤， AWS 管理控制台 而是在中使用它。除了避免安装之外，您也不需要配置凭证，也不需要指定区域。您的 AWS 管理控制台 会话为提供了此上下文 AWS CLI。有关 CloudShell更多信息以及用法示例，请参阅[使用 AWS CloudShell 来使用 AWS App Runner](api-cshell.md)。

# 使用 AWS CloudShell 来使用 AWS App Runner
<a name="api-cshell"></a>

AWS CloudShell 是一个基于浏览器、经过预先验证的 shell，您可以直接从启动。 AWS 管理控制台您可以使用首选的外壳（Bash PowerShell 或 Z shell AWS App Runner）对 AWS 服务（包括）运行 AWS CLI 命令。您无需下载或安装命令行工具，即可完成此操作。

您可以[AWS CloudShell 从启动 AWS 管理控制台，](https://docs.aws.amazon.com/cloudshell/latest/userguide/working-with-cloudshell.html#launch-options)用于登录控制台的 AWS 凭据将在新的 shell 会话中自动可用。这种对 AWS CloudShell 用户的预身份验证允许您在使用 AWS CLI 版本 2（预先安装在 shell 的计算环境中）与 App Runner 等 AWS 服务进行交互时跳过配置凭据。

**Topics**
+ [获取 IAM 权限 AWS CloudShell](#api-cshell.permissions)
+ [使用与 App Runner 互动 AWS CloudShell](#api-cshell.call-apprunner)
+ [使用验证您的 App Runner 服务 AWS CloudShell](#api-cshell.call-your-service)

## 获取 IAM 权限 AWS CloudShell
<a name="api-cshell.permissions"></a>

使用提供的访问管理资源 AWS Identity and Access Management，管理员可以向 IAM 用户授予权限，使他们能够访问 AWS CloudShell 和使用环境的功能。

管理员向用户授予访问权限的最快方法是通过 AWS 托管策略。[AWS 托管式策略](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies)是由 AWS创建和管理的独立策略。以下的 AWS 托管策略 CloudShell 可以附加到 IAM 身份：
+ `AWSCloudShellFullAccess`：授予使用权限，并 AWS CloudShell 具有对所有功能的完全访问权限。

 如果您想限制 IAM 用户可以执行的操作范围 AWS CloudShell，则可以创建使用`AWSCloudShellFullAccess`托管策略作为模板的自定义策略。有关限制中可供用户执行的操作的更多信息 CloudShell，请参阅*AWS CloudShell 用户指南*中的[使用 IAM 策略管理 AWS CloudShell 访问和使用情况](https://docs.aws.amazon.com/cloudshell/latest/userguide/sec-auth-with-identities.html)。

**注意**  
您的 IAM 身份还需要一项策略，该策略授予对 App Runner 进行调用的权限。有关更多信息，请参阅 [应用程序运行器如何与 IAM 配合使用](security_iam_service-with-iam.md)。

## 使用与 App Runner 互动 AWS CloudShell
<a name="api-cshell.call-apprunner"></a>

 AWS CloudShell 从启动后 AWS 管理控制台，您可以立即开始使用命令行界面与 App Runner 进行交互。

在以下示例中，您可以使用中的来检索有关您的某个 App Runner 服务的信息 CloudShell。 AWS CLI 

**注意**  
 AWS CLI 在中使用时 AWS CloudShell，您无需下载或安装任何其他资源。此外，由于已经在 Shell 中进行了身份验证，因此在进行调用之前无需配置凭证。

**Example 使用检索 App Runner 服务信息 AWS CloudShell**  

1. 从中 AWS 管理控制台，您可以 CloudShell 通过选择导航栏上的以下可用选项来启动：
   +  选择图 CloudShell 标。
   + 开始**cloudshell**在搜索框中键入内容，然后在搜索结果中看到该**CloudShell**选项时选择该选项。

1. 要在控制台会话 AWS 区域中列出您 AWS 账户中的所有当前 App Runner 服务，请在命令行中输入以下 CloudShell命令：

   ```
   $ aws apprunner list-services
   ```

   输出列出了您的服务的摘要信息。

   ```
   {
     "ServiceSummaryList": [
       {
         "ServiceName": "my-app-1",
         "ServiceId": "8fe1e10304f84fd2b0df550fe98a71fa",
         "ServiceArn": "arn:aws:apprunner:us-east-2:123456789012:service/my-app-1/8fe1e10304f84fd2b0df550fe98a71fa",
         "ServiceUrl": "psbqam834h.us-east-1.awsapprunner.com",
         "CreatedAt": "2020-11-20T19:05:25Z",
         "UpdatedAt": "2020-11-23T12:41:37Z",
         "Status": "RUNNING"
       },
       {
         "ServiceName": "my-app-2",
         "ServiceId": "ab8f94cfe29a460fb8760afd2ee87555",
         "ServiceArn": "arn:aws:apprunner:us-east-2:123456789012:service/my-app-2/ab8f94cfe29a460fb8760afd2ee87555",
         "ServiceUrl": "e2m8rrrx33.us-east-1.awsapprunner.com",
         "CreatedAt": "2020-11-06T23:15:30Z",
         "UpdatedAt": "2020-11-23T13:21:22Z",
         "Status": "RUNNING"
       }
     ]
   }
   ```

1. 要获取特定 App Runner 服务的详细描述，请在命令行中输入以下 CloudShell 命令，使用上一步中 ARNs检索到的命令之一：

   ```
   $ aws apprunner describe-service --service-arn arn:aws:apprunner:us-east-2:123456789012:service/my-app-1/8fe1e10304f84fd2b0df550fe98a71fa
   ```

   输出中列出了您指定的服务的详细描述。

   ```
   {
     "Service": {
       "ServiceName": "my-app-1",
       "ServiceId": "8fe1e10304f84fd2b0df550fe98a71fa",
       "ServiceArn": "arn:aws:apprunner:us-east-2:123456789012:service/my-app-1/8fe1e10304f84fd2b0df550fe98a71fa",
       "ServiceUrl": "psbqam834h.us-east-1.awsapprunner.com",
       "CreatedAt": "2020-11-20T19:05:25Z",
       "UpdatedAt": "2020-11-23T12:41:37Z",
       "Status": "RUNNING",
       "SourceConfiguration": {
         "CodeRepository": {
           "RepositoryUrl": "https://github.com/my-account/python-hello",
           "SourceCodeVersion": {
             "Type": "BRANCH",
             "Value": "main"
           },
           "CodeConfiguration": {
             "CodeConfigurationValues": {
               "BuildCommand": "[pip install -r requirements.txt]",
               "Port": "8080",
               "Runtime": "PYTHON_3",
               "RuntimeEnvironmentVariables": [
                 {
                   "NAME": "Jane"
                 }
               ],
               "StartCommand": "python server.py"
             },
             "ConfigurationSource": "API"
           }
         },
         "AutoDeploymentsEnabled": true,
         "AuthenticationConfiguration": {
           "ConnectionArn": "arn:aws:apprunner:us-east-2:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e"
         }
       },
       "InstanceConfiguration": {
         "CPU": "1 vCPU",
         "Memory": "3 GB"
       },
       "HealthCheckConfiguration": {
         "Protocol": "TCP",
         "Path": "/",
         "Interval": 10,
         "Timeout": 5,
         "HealthyThreshold": 1,
         "UnhealthyThreshold": 5
       },
       "AutoScalingConfigurationSummary": {
         "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-2:123456789012:autoscalingconfiguration/DefaultConfiguration/1/00000000000000000000000000000001",
         "AutoScalingConfigurationName": "DefaultConfiguration",
         "AutoScalingConfigurationRevision": 1
       }
     }
   }
   ```

## 使用验证您的 App Runner 服务 AWS CloudShell
<a name="api-cshell.call-your-service"></a>

[创建 App Runner 服务](manage-create.md)时，App Runner 会为您的服务的网站创建一个默认域名，并将其显示在控制台中（或在 API 调用结果中返回）。您可以使用拨 CloudShell 打您的网站并验证其是否正常运行。

例如，按照中所述创建 App Runner 服务后[App Runner 入门](getting-started.md)，在中运行以下命令 CloudShell：

```
$ curl https://qxuadi4qwp.us-east-2.awsapprunner.com/; echo
```

输出应显示预期的页面内容。

![\[浏览器窗口显示 AWS CloudShell 一个用于显示 App Runner 服务页面内容的命令\]](http://docs.aws.amazon.com/zh_cn/apprunner/latest/dg/images/api-cshell-curl.png)
