

终止支持通知：2026 年 5 月 20 日， AWS 将终止对的支持。 AWS SimSpace Weaver 2026 年 5 月 20 日之后，您将无法再访问 SimSpace Weaver 控制台或 SimSpace Weaver 资源。有关更多信息，请参阅[AWS SimSpace Weaver 终止支持](https://docs.aws.amazon.com/simspaceweaver/latest/userguide/simspaceweaver-end-of-support.html)。

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

# 修改项目以使用自定义容器
<a name="working-with_custom-containers_modify-project"></a>

这些说明假设您已经知道如何使用， AWS SimSpace Weaver 并希望提高应用程序存储和开发工作流程的 AWS 云 效率。

**先决条件**
+ 在 Amazon Elastic Container Registry (Amazon ECR) 中有一个自定义容器。有关创建自定义容器的更多信息，请参阅[创建自定义容器](working-with_custom-containers_create.md)。

**修改项目以使用自定义容器**

1. 为项目的模拟应用程序角色添加使用 Amazon ECR 的权限。

   1. 如果您目前没有具有以下权限的 IAM 策略，请创建该策略。我们建议使用策略名称 `simspaceweaver-ecr`。有关如何创建 IAM 策略的更多信息，请参阅《AWS Identity and Access Management 用户指南》中的[创建 IAM 策略](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html)。

      ```
      {
          "Version": "2012-10-17",		 	 	 
          "Statement": [
              {
                  "Sid": "Statement",
                  "Effect": "Allow",
                  "Action": [
                      "ecr:BatchGetImage",
                      "ecr:GetDownloadUrlForLayer",
                      "ecr:GetAuthorizationToken"
                  ],
                  "Resource": "*"
              }
          ]
      }
      ```

   1. 查找项目的模拟应用程序角色的名称：

      1. 在文本编辑器中，打开 CloudFormation 模板：

         ```
         sdk-folder\PackagingTools\sample-stack-template.yaml
         ```

      1. 在 `WeaverAppRole` 下找到 `RoleName` 属性。该值是项目的模拟应用程序角色的名称。  
**Example**  

         ```
         AWSTemplateFormatVersion: "2010-09-09"
         Resources:
           WeaverAppRole:
             Type: 'AWS::IAM::Role'
             Properties:
               RoleName: 'weaver-MySimulation-app-role'
               AssumeRolePolicyDocument:
                 Version: "2012-10-17"		 	 	 
                 Statement:
                 - Effect: Allow
                   Principal:
                     Service:
                       - 'simspaceweaver.amazonaws.com'
         ```

   1. 将 `simspaceweaver-ecr` 策略附加到项目的模拟应用程序角色。有关如何附加策略的更多信息，请参阅《AWS Identity and Access Management 用户指南》中的[添加和删除 IAM 身份权限](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html)。**

   1. 导航到`sdk-folder`并运行以下命令以更新示例 SimSpace Weaver 堆栈：

      ```
      python setup.py --cloudformation
      ```

1. 在项目的模拟架构中指定您的容器映像。
   + 您可以在 `simulation_properties` 下添加可选 `default_image` 属性，为所有域指定默认的自定义容器映像。
   + 在 `app_config` 中为要使用自定义容器映像的域添加 `image` 属性。指定 Amazon ECR 存储库 URI 作为值。您可以为每个域指定不同的映像。
     + 如果没有为域指定 `image`，但已指定 `default_image`，则该域中的应用程序将使用默认映像。
     + 如果`image`未为网域指定且`default_image`未指定，则该网域中的应用程序将在标准 SimSpace Weaver 容器中运行。  
**Example 包含自定义容器设置的架构片段**  

   ```
   sdk_version: "1.17.0"
   simulation_properties:
     log_destination_service: "logs"
     log_destination_resource_name: "MySimulationLogs"
     default_entity_index_key_type: "Vector3<f32>"
     default_image: "111122223333.dkr.ecr.us-west-2.amazonaws.com/my-ecr-repository:latest" # image to use if no image specified for a domain
   domains:
     MyCustomDomain:
       launch_apps_via_start_app_call: {}
       app_config:
         package: "s3://weaver-myproject-111122223333-us-west-2/MyViewApp.zip" 
         launch_command: ["MyViewApp"]  
         required_resource_units:
           compute: 1
         endpoint_config:
           ingress_ports:
             - 7000
         image: "111122223333.dkr.ecr.us-west-2.amazonaws.com/my-ecr-repository:latest" # custom container image to use for this domain 
     MySpatialDomain:
       launch_apps_by_partitioning_strategy:
         partitioning_strategy: "MyGridPartitioning"
         grid_partition:
           x: 2
           y: 2
       app_config:
         package: "s3://weaver-myproject-111122223333-us-west-2/MySpatialApp.zip" 
         launch_command: ["MySpatialApp"] 
         required_resource_units:
           compute: 1
         image: "111122223333.dkr.ecr.us-west-2.amazonaws.com/my-ecr-repository:latest" # custom container image to use for this domain
   ```

1. 照常构建和上传项目。