

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Definisci un progetto Terraform
<a name="tutorial-deploy-terraform-define"></a>

In questo tutorial, definirai un progetto Terraform.

1. Crea una directory chiamata`my-pcluster-api`.

   Tutti i file che creerai si troveranno all'interno di questa directory.

1. Crea il file `provider.tf` per configurare il AWS provider.

   ```
   provider "aws" {
     region  = var.region
     profile = var.profile
   }
   ```

1. Crea il file `main.tf` per definire le risorse utilizzando il ParallelCluster modulo.

   ```
   module "parallelcluster_pcluster_api" {
     source = "aws-tf/parallelcluster/aws//modules/pcluster_api"
     version = "1.1.0"
   
     region                = var.region
     api_stack_name        = var.api_stack_name
     api_version           = var.api_version
   
     parameters = {
       EnableIamAdminAccess = "true"
     }
   }
   ```

1. Crea il file `variables.tf` per definire le variabili che possono essere iniettate per questo progetto.

   ```
   variable "region" {
     description = "The region the ParallelCluster API is deployed in."
     type        = string
     default     = "us-east-1"
   }
   
   variable "profile" {
     type        = string
     description = "The AWS profile used to deploy the clusters."
     default     = null
   }
   
   variable "api_stack_name" {
     type        = string
     description = "The name of the CloudFormation stack used to deploy the ParallelCluster API."
     default     = "ParallelCluster"
   }
   
   variable "api_version" {
     type        = string
     description = "The version of the ParallelCluster API."
   }
   ```

1. Crea il file `terraform.tfvars` per impostare valori arbitrari per le variabili. 

   Il file seguente implementa un' ParallelCluster API 3.11.1 `us-east-1` utilizzando il nome dello stack. `MyParallelClusterAPI-3111` Potrai fare riferimento a questa distribuzione dell' ParallelCluster API utilizzando il nome dello stack. 
**Nota**  
L'`api_version`assegnazione nel codice seguente può essere sostituita con qualsiasi versione supportata AWS ParallelCluster . 

   ```
   region = "us-east-1"
   api_stack_name = "MyParallelClusterAPI-3111"
   api_version = "3.11.1"
   ```

1. Crea il file `outputs.tf` per definire gli output restituiti da questo progetto.

   ```
   output "pcluster_api_stack_outputs" {
     value = module.parallelcluster_pcluster_api.stack_outputs
   }
   ```

   La cartella del progetto è:

   ```
   my-pcluster-api
   ├── main.tf - Terraform entrypoint to define the resources using the ParallelCluster module.
   ├── outputs.tf - Defines the outputs returned by Terraform.
   ├── providers.tf - Configures the AWS provider.
   ├── terraform.tfvars - Set the arbitrary values for the variables, i.e. region, PCAPI version, PCAPI stack name
   └── variables.tf - Defines the variables, e.g. region, PCAPI version, PCAPI stack name.
   ```