This guide explains how to generate AWS ParallelCluster configuration files automatically from your Terraform infrastructure.
After deploying AWS infrastructure with Terraform, you need a cluster-config.yaml file that references the created resources (subnets, security groups, EFS, etc.). This repository provides multiple approaches to generate this configuration automatically.
The simplest approach is to use the provided makefile commands:
# Deploy infrastructure and generate configs
make apply
# Create a cluster
make create-cluster NAME=cluster1That's it! The make apply command will run terraform to deploy the infrastructure and generate the configuration files. Then make create-cluster NAME=cluster1 will create a cluster named "cluster1" using the generated configuration.
The generated configuration includes these Terraform-managed resources:
| Component | Purpose | Configuration |
|---|---|---|
| VPC | Isolated network | 10.0.0.0/16 CIDR |
| Public Subnet | Head node | Internet access, Elastic IP |
| Private Subnet | Compute nodes | NAT Gateway access only |
| Security Groups | Network access | SSH, SLURM, NFS rules |
| EFS File System | Shared storage | Encrypted, multi-AZ |
| NAT Gateway | Compute internet | Package installations |
You can build custom AMIs for your clusters using the makefile commands:
# List existing custom images
make image-list
# Build a custom image
make image-build ID=my-custom-image
# Check image build status
make image-status ID=my-custom-image
# Delete a custom image
make image-delete ID=my-custom-imageThe image build process uses the auto-generated imagebuilder-config-generated.yaml file. You can optionally specify a custom configuration file with the CONFIG parameter:
make image-build ID=my-custom-image CONFIG=my-custom-imagebuilder-config.yamlYou can also wait for the build to complete by adding the WAIT=true parameter:
make image-build ID=my-custom-image WAIT=trueOnce your custom image is built, you can reference it in your cluster configuration by updating the Image section in the generated cluster configuration file:
Image:
CustomAmi: ami-0123456789abcdef0 # Your custom AMI IDOr set it in your Terraform variables to have it automatically included in the generated configuration.
The auto-generated cluster-config.yaml includes:
Region: us-east-2 # From terraform
HeadNode:
Networking:
SubnetId: subnet-xyz123 # From terraform output
SecurityGroups: [sg-abc456] # From terraform output
Scheduling:
SlurmQueues:
- Networking:
SubnetIds: [subnet-def789] # From terraform output
SharedStorage:
- EfsSettings:
FileSystemId: fs-ghi012 # From terraform output- Head Node: t3.medium with Elastic IP
- Compute Queues:
debug: c5.xlarge instances (0-5 nodes)
- Storage: EFS mounted at
/shared
Customize infrastructure before deployment in terraform.tfvars:
# Network customization
vpc_cidr = "172.16.0.0/16"
head_node_subnet_cidr = "172.16.1.0/24"
# Security customization
ssh_allowed_cidr_blocks = ["203.0.113.0/24"] # Your IP range
ssh_key_name = "my-aws-keypair"
# EFS customization
efs_performance_mode = "maxIO"
efs_throughput_mode = "provisioned"Modify the generated cluster-config-generated.yaml:
# Change head node instance type
HeadNode:
InstanceType: t3.medium
# Add more queues
SlurmQueues:
- Name: gpu
ComputeResources:
- Name: p3xlarge
InstanceType: p3.xlarge
MinCount: 0
MaxCount: 2
# Use custom AMI
Image:
CustomAmi: ami-0123456789abcdef0# Show all available commands
make help
# Setup initial configuration
make setup
# Check prerequisites
make check-prereqs
# Deploy infrastructure
make apply
# Generate configuration files
make generate-config
# Validate configuration
make validate-config
# Create a cluster
make create-cluster NAME=mycluster
# SSH to cluster head node
make ssh NAME=mycluster
# Delete a cluster
make delete-cluster NAME=mycluster
# Show infrastructure and cluster status
make status
# Show Terraform outputs
make outputs
# Destroy all infrastructure
make destroy-
Configure Terraform:
make setup vim terraform/terraform.tfvars # Edit your settings -
Deploy Infrastructure and Generate Config:
make apply
-
Validate Configuration:
make validate-config
-
Deploy Cluster:
make create-cluster NAME=my-research-cluster
-
Monitor Cluster Status:
make status
-
Connect to Cluster:
make ssh NAME=my-research-cluster
β "Terraform state file not found"
# Solution: Deploy infrastructure first
make applyβ "Could not retrieve subnet ID"
# Check Terraform outputs
make outputsβ "SSH key 'xyz' does not exist"
# List available keys
aws ec2 describe-key-pairs --query 'KeyPairs[].KeyName'
# Update SSH key in terraform.tfvars and regenerate
make generate-configβ "Invalid cluster configuration"
# Validate before deployment
make validate-config- β Restrict SSH access to your IP range
- β Use private subnets for compute nodes
- β Enable EFS encryption
- β Use security groups for least privilege
# terraform.tfvars
ssh_allowed_cidr_blocks = ["203.0.113.0/24"] # Your office IP range
efs_encrypted = true# In cluster-config-generated.yaml
SlurmQueues:
- Name: memory-optimized
ComputeResources:
- Name: r5xlarge
InstanceType: r5.xlarge
MinCount: 0
MaxCount: 10ComputeResources:
- Name: spot-instances
InstanceType: c5.xlarge
MinCount: 0
MaxCount: 20
SpotPrice: 0.05- Modify
terraform.tfvars - Run
make apply - Regenerate cluster config if needed with
make generate-config
- Modify the generated YAML file
- Update existing cluster:
pcluster update-cluster - Or create new cluster with new config