---
title: "Deploy development virtual machines on AWS"
description: "Deploy development VMs on AWS with Terraform and Ansible, featuring multiple OS options, automated Netprobe deployment, and flexible configuration."
url: "https://docs.itrsgroup.com/docs/geneos/7.11.0/collection/cloud-native-deployments/deploying-via-terraform/instance-provisioning/aws-instance-provisioning/index.html"
---
This page details the Terraform configuration required for deploying development virtual machines (VMs) on AWS with multiple operating system options and automated Netprobe deployment. This environment creates development VMs on AWS with:

- Multiple operating system options (Ubuntu 22.04/24.04 LTS, RHEL 7, RHEL 8, and RHEL 9)
- Ansible deployment automation  
- SSH key authentication
- Configurable VM specifications
- Resource tagging for organization

## Template files

The environment contains the following Terraform configuration files:

- `main.tf` — the main configuration that provisions VM instances and triggers the Ansible deployment
- `variables.tf` — variable definitions for all configurable parameters
- `outputs.tf` — output definitions for deployment information
- `providers.tf` — AWS provider configuration
- `versions.tf` — Terraform and provider version constraints
- `terraform.tfvars.[os].example` — configuration file for your operating system

## Prerequisites

1. [Terraform](https://www.terraform.io/downloads) version 1.0 or higher installed

2. [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) version 2.0 or higher installed  

3. AWS authentication configured

   Select one method:

   ```bash
   # Method 1: Default profile
   aws configure
   
   # Method 2: Named profile  
   aws configure --profile my-profile
   
   # Method 3: Environment variables
   export AWS_ACCESS_KEY_ID="your-access-key"
   export AWS_SECRET_ACCESS_KEY="your-secret-key"
   export AWS_DEFAULT_REGION="us-east-1"
   ```

4. SSH key pair for instance access (choose one method)

   - Import an existing public key to AWS:

      ```bash
      # Generate SSH key pair if you don't already have one
      ssh-keygen -t rsa -b 4096 -f ../../../../../resources/id_rsa

      # Import the public key as an EC2 key pair
      aws ec2 import-key-pair --key-name my-key --public-key-material fileb://../../../../../resources/id_rsa.pub
      ```

   - Or create an AWS-managed key pair and download the private key:

      ```bash
      aws ec2 create-key-pair --key-name my-key --query 'KeyMaterial' --output text > my-key.pem
      chmod 400 my-key.pem
      ```

5. IAM permissions, where the user or role must have:
   - EC2 full access
   - VPC full access  
   - IAM `PassRole` permission (if using roles)

## Authentication overview

This deployment requires two types of authentication:

1. Terraform authentication (infrastructure creation) to allow Terraform to create virtual machines, networks, and cloud resources. For AWS, you need to configure the AWS CLI profiles or environment variables. Select only one method:

   - Default AWS CLI profile — makes use of the default AWS CLI profile configured on your system.

      ```hcl
      aws_region = "us-east-1"
      key_name = "your-key-pair-name"
      ```

   - Specific AWS CLI profile — makes use of a named AWS CLI profile.

      ```hcl
      aws_region = "us-east-1"
      aws_profile = "my-profile"
      key_name = "your-key-pair-name"
      ```

   - Assume IAM role — assumes a specific IAM role for deployment.

      ```hcl
      aws_region = "us-east-1"
      assume_role_arn = "arn:aws:iam::123456789012:role/TerraformRole"
      assume_role_session_name = "terraform-deployment"
      key_name = "your-key-pair-name"
      ```

2. Application authentication (cloud storage access) to allow applications running on virtual machines to download the deployment resources from the respective cloud storage. This is configured in the `netprobe.yml` file for each environment. Refer to [AWS authentication](https://docs.itrsgroup.com/docs/geneos/7.11.0/collection/cloud-native-deployments/quickstart/aws-cloudformation-quickstart/index.html#create-an-instance-profile-with-an-iam-role) for detailed authentication configuration.

## Deployment setup

1. Copy the example configuration.

   ```bash
   # For Ubuntu 22.04 (default)
   cp terraform.tfvars.example terraform.tfvars
   
   # For Ubuntu 24.04
   cp terraform.tfvars.ubuntu24.example terraform.tfvars
   
   # For RHEL 8
   cp terraform.tfvars.rhel8.example terraform.tfvars
   
   # For RHEL 9
   cp terraform.tfvars.rhel9.example terraform.tfvars
   ```

2. Update the `terraform.tfvars` [configuration file](#configuration-files) with your AWS settings.

   ```bash
   nano terraform.tfvars
   ```

3. [Deploy](#terraform-commands) the infrastructure.

   ```bash
   terraform init
   terraform plan
   terraform apply
   ```

## Configuration files

Select the appropriate configuration file for your operating system:

| Operating system | Configuration file |
|-------|-------|
| Ubuntu 22.04 LTS (default) | `terraform.tfvars.example` |
| Ubuntu 24.04 LTS | `terraform.tfvars.ubuntu24.example` |
| RHEL 8 | `terraform.tfvars.rhel8.example` |
| RHEL 9 | `terraform.tfvars.rhel9.example` |

In the selected configuration file, configure the parameters outlined below.

### AWS account configuration

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| aws_region | AWS region for deployment | "us-east-1" | Yes |
| aws_profile | AWS CLI profile to use | null | No |

### EC2 instance configuration

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| aws_instance_profile | IAM instance profile name to attach to EC2 instances | null | Yes |

You must create the instance profile before running Terraform. This instance profile will be attached to the VM instances during creation. To create an instance profile:

   ```bash
   # Create the IAM role for EC2 instances
   aws iam create-role \
      --role-name dev-instance-role \
      --assume-role-policy-document file://trust-policy.json

   # Create the instance profile
   aws iam create-instance-profile \
      --instance-profile-name dev-instance-profile

   # Add role to instance profile
   aws iam add-role-to-instance-profile \
      --instance-profile-name dev-instance-profile \
      --role-name dev-instance-role
   ```

### Deployment configuration

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `deployment_count` | Number of identical VM deployments to create | 1 | Yes |
| `tags` | Resource tags to assign to all created resources | {} | No |

### Network configuration

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `subnet_id` | Subnet ID for deployment | "" - uses default VPC's first subnet | Yes |
| `security_group_ids` | Security group IDs | [] - creates default security group | Yes |

### Virtual machine configuration

Virtual machine configurations are based on the [Netprobe system requirements](https://docs.itrsgroup.com/docs/geneos/7.11.0/collection/netprobe/installation/quickstart-linux-and-other-platforms/index.html#system-requirements). The default instance type follows the [ITRS AWS AMI](https://aws.amazon.com/marketplace/pp/prodview-vsgileoae4w5w) specifications.

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `vm_name` | Base name for EC2 instances | "vm-template" | Yes |
| `vm_type` | EC2 instance type | "t3.large" | Yes |
| `operating_system` | OS to use: "ubuntu22", "ubuntu24", "rhel7", "rhel8", "rhel9" | "ubuntu22" | Yes |
| `ami_name_filter` | AMI name filter pattern | varies by OS | Yes |
| `ami_owners` | List of AMI owner IDs | ["099720109477"] | Yes |
| `architecture` | AMI architecture | "x86_64" | Yes |

### SSH access configuration

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `ssh_public_key` | AWS EC2 key pair name for SSH access | "id_rsa" | Yes |
| `ssh_user` | SSH username for VM access | "ubuntu" | Yes |

### Ansible deployment configuration

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `ansible_playbook_path` | Path to Ansible playbook | "../../../../ansible/netprobe.yml" | Yes |
| `ansible_operation` | [Deployment operation](https://docs.itrsgroup.com/docs/geneos/7.11.0/collection/cloud-native-deployments/deploying-via-terraform/ansible-configuration/index.html#ansible-supported-operations)  | "install" | Yes |
| `additional_args` | Additional Ansible playbook arguments | ""  - Use `-vvv` for verbose output | No |

## Terraform commands

Run the following Terraform commands to deploy the infrastructure.

| Command | Command |
|-----------|-------------|
| Initialize Terraform | ```bash
terraform init
``` |
| Plan the deployment | ```bash
terraform plan -var-file="terraform.tfvars"
``` |
| Apply the deployment | ```bash
terraform apply -var-file="terraform.tfvars"
``` |
| Show the deployment options | ```bash
terraform output
``` |
| Destroy the deployment | ```bash
terraform destroy -var-file="terraform.tfvars"
``` |

## Resources created

The following AWS infrastructure resources and outputs will be created:

| Resource | Description |
|-----------|-------------|
| EC2 instance | Selected OS version with automatic AMI detection |
| Ansible deployment | Automated Netprobe service installation |

## Outputs

The following outputs will be available after deployment:

| Output | Description |
|--------|-------------|
| `Instance_IP` | Public IP address of the EC2 instance |
| `Instance_DNS` | Public DNS name of the EC2 instance |
| `AMI_ID` | AMI ID automatically detected for the selected operating system |
| `Operating_System` | Operating system version selected |
| `Default_User` | Default SSH user for the operating system |
| `AWS_Region` | AWS region where the instance is deployed |
| `deployment_summary` | Summary of all deployed resources |

## Ansible integration

Ansible playbooks are automatically executed after the creation of the virtual machine. These are used to:

- Configure the Netprobe service.
- Set up monitoring connections to the Gateway.
- Apply environment-specific settings.
- Install the required dependencies.

## Troubleshooting

You can run the given commands if you encounter the following issues:

| Issue type | Command |
|------------|---------|
| Authentication issues | ```bash
# Check current AWS identity
aws sts get-caller-identity
# Check AWS CLI configuration
aws configure list
# Test specific profile
aws sts get
``` |
| Instance issues | ```bash
# Check instance status via AWS CLI
aws ec2 describe-instances --instance-ids <instance-id>
# Check via Terraform
terraform show
# View Terraform state
terraform state list
``` |
| AMI detection issues | ```bash
# Check available Ubuntu AMIs
aws ec2 describe-images --owners 099720109477 \
--filters "Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"
# Check available RHEL AMIs
aws ec2 describe-images --owners 309956199498 \
--filters "Name=name,Values=RHEL-9*"
``` |
| SSH connection issues | ```bash
# Check security group rules
aws ec2 describe-security-groups --group-ids <security-group-id>
# Verify key pair exists
aws ec2 describe-key-pairs --key-names <key-name>
# Test SSH connection
ssh -i /path/to/key.pem ubuntu@<instance-ip>
``` |
| Ansible deployment issues | ```bash
# Check Ansible logs in Terraform output
terraform apply -auto-approve
# Manual Ansible execution
ansible-playbook -i <instance-ip>, ../../../../ansible/netprobe.yml \
--private-key ../../../../../resources/id_rsa \
--user ubuntu \
--extra-vars "operation=install"
``` |

## Netprobe configuration

The `netprobe.yml` file contains Ansible configuration for Netprobe deployment. For general configuration structure and available parameters, refer to [Ansible configuration](https://docs.itrsgroup.com/docs/geneos/7.11.0/collection/cloud-native-deployments/deploying-via-terraform/ansible-configuration/index.html).

Update the following environment-specific settings in `netprobe.yml` file for your AWS development environment:

### SSH configuration

```yaml
# SSH connection configuration (required)
ansible_ssh_private_key_file: "../../../../../resources/id_rsa"
ansible_ssh_common_args: "-o ControlMaster=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
```

### Bootstrap configuration

```yaml
# Set to false for dev environments (minimal bootstrap)
perform_bootstrap: false

# AWS-specific bootstrap if perform_bootstrap is true
additional_bootstrap: ""
```

### Cloud provider configuration

For AWS S3 authentication configuration (downloading deployment resources), see [authentication overview](#authentication-overview).

```yaml
resources:
  source:
    aws:
      # Authentication configuration varies by method
  container: geneos  # S3 bucket name
  # Resource paths
  path: netprobe.tar.gz
  setupfile:
    path: netprobe.setup_template.xml
```

### Gateway connection

```yaml
env_vars:
  # Gateway information (configure for your setup)
  GATEWAY_HOST: "0.0.0.0"
  GATEWAY_PORT: "7039"
```

### Netprobe connection

```yaml
env_vars:
  # Netprobe information
  SERVICE_PARAM: "-port 7036 -setup {{ workspace_dir }}/{{ resources.setupfile.path | basename }}"
```

