

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

# Definir um projeto Terraform
<a name="tutorial-deploy-terraform-define"></a>

Neste tutorial, você definirá um projeto Terraform.

1. Crie um diretório denominado `my-pcluster-api`.

   Todos os arquivos que você criar estarão dentro desse diretório.

1. Crie o arquivo `provider.tf` para configurar o AWS provedor.

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

1. Crie o arquivo `main.tf` para definir os recursos usando o ParallelCluster módulo.

   ```
   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. Crie o arquivo `variables.tf` para definir as variáveis que podem ser injetadas neste projeto.

   ```
   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. Crie o arquivo `terraform.tfvars` para definir valores arbitrários para as variáveis. 

   O arquivo abaixo implanta uma ParallelCluster API 3.11.1 `us-east-1` usando o nome da pilha. `MyParallelClusterAPI-3111` Você poderá referenciar essa implantação de ParallelCluster API usando o nome da pilha. 
**nota**  
A `api_version` atribuição no código a seguir pode ser substituída por qualquer AWS ParallelCluster versão compatível. 

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

1. Crie o arquivo `outputs.tf` para definir os resultados gerados por esse projeto.

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

   O diretório do projeto é:

   ```
   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.
   ```