

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 步驟 3：設定您的環境以執行指令碼
<a name="migrating-to-systems-manager-script-parameters"></a>

使用下列命令將您的環境設定為執行指令碼。

```
pipenv install -r requirements.txt
pipenv shell
```

**注意**  
 目前，指令碼只能在 Application Manager 中佈建單層應用程式。例如，如果您在同一堆疊中為兩層執行指令碼兩次，則指令碼會在 Application Manager 中建立兩個不同的應用程式。

設定環境之後，請檢閱指令碼參數。您可以執行 `python3 stack_exporter.py --help`命令來檢視遷移指令碼的可用選項。


****  

| 參數 | Description | 必要 | Type | 預設值 | 
| --- | --- | --- | --- | --- | 
| --layer-id | 匯出此 OpsWorks layer ID 的 CloudFormation 範本。 | 是 | string |  | 
| --region | OpsWorks 堆疊 AWS 的區域。如果您的 OpsWorks 堆疊區域和 API 端點區域不同，請使用堆疊區域。這與 OpsWorks 堆疊的其他資源部分 （例如 EC2 執行個體和子網路） 相同。 | 否 | string | us-east-1 | 
| --provision-application | 根據預設，指令碼會佈建 CloudFormation 範本匯出的應用程式。將此參數傳遞至值為 FALSE 的指令碼，以略過 CloudFormation 範本的佈建。 | 否 | Boolean | TRUE | 
| --launch-template | 此參數定義是使用現有的啟動範本，還是建立新的啟動範本。您可以建立新的啟動範本，使用建議的執行個體屬性，或使用符合線上執行個體的執行個體屬性。 有效值包含： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opsworks/latest/userguide/migrating-to-systems-manager-script-parameters.html)  | 否 | string | RECOMMENDED | 
| --system-updates |  定義是否要在執行個體開機時執行核心和套件更新。 有效值包含： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opsworks/latest/userguide/migrating-to-systems-manager-script-parameters.html)  | 否 | string | ALL\$1UPDATES | 
| --http-username | Systems Manager SecureString 參數的名稱，存放用於向包含自訂技術指南的 HTTP 封存進行身分驗證的使用者名稱。 | 否 | string |  | 
| --http-password | Systems Manager SecureString 參數的名稱，存放用於向包含自訂技術指南的 HTTP 封存進行身分驗證的密碼。 | 否 | string |  | 
| --repo-private-key | Systems Manager SecureString 參數的名稱，存放用於向包含自訂技術指南的儲存庫進行身分驗證的 SSH 金鑰。如果儲存庫位於 GitHub，您必須產生新的 Ed25519 SSH 金鑰。如果您未產生新的 Ed25519 SSH 金鑰，則與 GitHub 儲存庫的連線會失敗。 | 否 | string |  | 
| --lb-type | 遷移現有負載平衡器時要建立的負載平衡器類型，如果有的話。 有效值包含： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opsworks/latest/userguide/migrating-to-systems-manager-script-parameters.html)  | 否 | string | ALB | 
| --lb-access-logs-path | 儲存負載平衡器存取日誌的現有 S3 儲存貯體和字首路徑。S3 儲存貯體和負載平衡器必須位於相同的區域。如果您未提供值，且--lb-type參數值設定為 None，則指令碼會建立新的 S3 儲存貯體和字首。請確定此字首有適當的儲存貯體政策。 | 否 | string |  | 
| --enable-instance-protection | 如果設定為 TRUE ，指令碼會為您的 Auto Scaling 群組建立自訂終止政策 (Lambda 函數）。具有protected\$1instance標籤的 EC2 執行個體受到縮減事件的保護。將protected\$1instance標籤新增至您要保護免於縮減事件的每個 EC2 執行個體。 | 否 | Boolean | FALSE | 
| --command-logs-bucket | 用來存放 AWS ApplyChefRecipe和 MountEBSVolumes日誌的現有 S3 儲存貯體名稱。如果您未提供值，指令碼會建立新的 S3 儲存貯體。 | 否 | string | aws-opsworks-application-manager-logs-account-id | 
| --custom-json-bucket | 儲存自訂 JSON 的現有 S3 儲存貯體名稱。如果您未提供值，指令碼會建立新的 S3 儲存貯體。 | 否 | string | aws-apply-chef-application-manager-transition-data-account-id | 

**備註**：
+ 如果您使用私有 GitHub 儲存庫，則必須為 SSH 建立新的`Ed25519`主機金鑰。這是因為 GitHub 變更了 SSH 中支援的金鑰，並移除了未加密的 Git 通訊協定。如需`Ed25519`主機金鑰的詳細資訊，請參閱 GitHub 部落格文章[改善 Git GitHub 通訊協定安全性](https://github.blog/2021-09-01-improving-git-protocol-security-github/)。產生新的`Ed25519`主機金鑰後，請為 SSH 金鑰建立 Systems Manager `SecureString` 參數，並使用 `SecureString` 參數名稱做為 `--repo-private-key` 參數的值。如需如何建立 Systems Manager `SecureString` 參數的詳細資訊，請參閱*AWS Systems Manager 《 使用者指南*》中的[建立 SecureString 參數 (AWS CLI)](https://docs.aws.amazon.com/systems-manager/latest/userguide/param-create-cli.html#param-create-cli-securestring) 或[建立 Systems Manager 參數 （主控台）](https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-create-console.html)。
+ `--http-username`、 `--http-password`和 `--repo-private-key` 參數是指 Systems Manager `SecureString` 參數的名稱。當您執行`AWS-ApplyChefRecipes`文件時，遷移指令碼會使用這些參數。
+ `--http-username` 參數要求您也指定 `--http-password` 參數的值。
+  `--http-password` 參數要求您也指定 `--http-username` 參數的值。
+ 請勿同時設定 `--http-password`和 的值`--repo-private-key`。提供 SSH 金鑰 (`--repo-private-key`) 的 Systems Manager `SecureString` 參數名稱，或儲存庫使用者名稱 (`--http-username`) 和密碼 ()`--http-password`。