

終止支援通知： 將於 2026 AWS 年 5 月 20 日結束對 的支援 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. 在 下尋找 `RoleName` 屬性`WeaverAppRole`。值是專案模擬應用程式角色的名稱。  
**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. 在專案的模擬結構描述中指定您的容器映像。
   + 您可以在 下新增選用`default_image`屬性`simulation_properties`，以指定所有網域的預設自訂容器映像。
   + 針對您要使用自訂容器映像`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. 照常建置和上傳您的專案。