

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

# 部署叢集
<a name="tutorial-create-cluster-terraform-deploy"></a>

若要部署叢集，請依序執行標準 Terraform 命令。

**注意**  
此範例假設您已在帳戶中部署 ParallelCluster API。

1. 建置專案：

   ```
   terraform init
   ```

1. 定義部署計畫：

   ```
   terraform plan -out tfplan
   ```

1. 部署計劃：

   ```
   terraform apply tfplan
   ```

## 使用叢集部署 ParallelCluster API
<a name="tutorial-create-cluster-terraform-deploy-api"></a>

如果您尚未部署 ParallelCluster API，而且想要使用叢集部署它，請變更下列檔案：
+ `main.tf`

  ```
  module "pcluster" {
    source  = "aws-tf/aws/parallelcluster"
    version = "1.0.0"
  
    region                = var.region
    api_stack_name        = var.api_stack_name
    api_version           = var.api_version
    deploy_pcluster_api   = true
    parameters = {
      EnableIamAdminAccess = "true"
    }
    
    template_vars         = local.config_vars
    cluster_configs       = local.cluster_configs
    config_path           = "config/clusters.yaml"
  }
  ```
+ `providers.tf`

  ```
  provider "aws-parallelcluster" {
    region   = var.region
    profile  = var.profile
    endpoint = module.pcluster.pcluster_api_stack_outputs.ParallelClusterApiInvokeUrl
    role_arn = module.pcluster.pcluster_api_stack_outputs.ParallelClusterApiUserRole
  }
  ```