

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

# 使用 Terraform 對叢集部署進行故障診斷
<a name="troubleshooting-v3-terraform"></a>

本節與使用 Terraform 部署的叢集相關。

## 找不到 ParallelCluster API
<a name="troubleshooting-v3-terraform-parallelcluster-nf"></a>

規劃可能會失敗，因為找不到 ParallelCluster API。在這種情況下，傳回的錯誤會如下：

```
Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Unable to retrieve ParallelCluster API cloudformation stack.
│ 
│   with provider["registry.terraform.io/aws-tf/aws-parallelcluster"],
│   on providers.tf line 6, in provider "aws-parallelcluster":
│    6: provider "aws-parallelcluster" {
│ 
│ operation error CloudFormation: DescribeStacks, https response error StatusCode: 400, RequestID: REQUEST_ID, api error ValidationError: Stack with id PCAPI_STACK_NAME does not exist
```

若要解決此錯誤，請在要建立叢集的帳戶中部署 ParallelCluster API。請參閱 [使用 Terraform 建立叢集](tutorial-create-cluster-terraform.md)。

## 使用者無權呼叫 ParallelCluster API
<a name="troubleshooting-v3-terraform-parallelcluster-na"></a>

規劃可能會失敗，因為您擔任部署 Terraform 專案的 IAM 角色/使用者沒有與 ParallelCluster API 互動的許可。在這種情況下，傳回的錯誤會如下：

```
Planning failed. Terraform encountered an error while generating this plan.

│ Error: 403 Forbidden
│ 
│   with module.parallelcluster_clusters.module.clusters[0].pcluster_cluster.managed_configs["DemoCluster01"],
│   on .terraform/modules/parallelcluster_clusters/modules/clusters/main.tf line 35, in resource "pcluster_cluster" "managed_configs":
│   35: resource "pcluster_cluster" "managed_configs" {
│ 
│ {{"Message":"User: USER_ARN is not authorized to perform: execute-api:Invoke on resource: PC_API_REST_RESOURCE with an explicit deny"}
│ }
```

若要解決此錯誤，請設定 ParallelCluster 提供者，使其使用 ParallelCluster API 角色與 API 互動。

```
provider "aws-parallelcluster" {
  region         = var.region
  profile        = var.profile
  api_stack_name = var.api_stack_name
  **use_user_role** **= true**
}
```