No description
  • HCL 84.4%
  • Shell 15.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-13 15:43:03 +02:00
test chore(tests): clean unnecessary statement 2026-08-13 15:38:10 +02:00
user_data initial import 2026-08-12 23:38:41 +02:00
.gitignore initial import 2026-08-12 23:38:41 +02:00
ami.tf initial import 2026-08-12 23:38:41 +02:00
CHANGELOG.md feat(module): open port 2222 in addition to 22 when setting var.network.protocols.ssh 2026-08-13 15:43:03 +02:00
iam.tf initial import 2026-08-12 23:38:41 +02:00
main.tf initial import 2026-08-12 23:38:41 +02:00
main.tftest.hcl initial import 2026-08-12 23:38:41 +02:00
network.tf initial import 2026-08-12 23:38:41 +02:00
outputs.tf initial import 2026-08-12 23:38:41 +02:00
providers.tf initial import 2026-08-12 23:38:41 +02:00
README.md initial import 2026-08-12 23:38:41 +02:00
ssh.tf initial import 2026-08-12 23:38:41 +02:00
variables.tf initial import 2026-08-12 23:38:41 +02:00
vpc.tf feat(module): open port 2222 in addition to 22 when setting var.network.protocols.ssh 2026-08-13 15:43:03 +02:00
wireguard.tf initial import 2026-08-12 23:38:41 +02:00

AWS EC2

This module creates a dual-stack (IPv4 + Amazon-provided IPv6) EC2 instance and its associated resources.

Dependencies

When using wireguard, this module depends on bash, jq and wg.

Usage example

module "ec2" {
  source = "git@adyxax.org:adyxax.org/tofu-module-aws-ec2?depth=1&ref=1.0.0"

  instance_type = "m7a.large"
  name          = "test"
  network = {
    fqdn      = "test.adyxax.org"
    subnet_id = aws_subnet.main[data.aws_availability_zones.main.names[0]].id
  }
  operating_system = "FreeBSD-15"
  vpc_id           = aws_vpc.main.id
}

Post installation configuration steps

  • The instance SSH private key is published to Secrets Manager under a secret which name is stored as the ssh_private_key_secret instance tag. Load it into ssh-agent with:

    aws --profile tests secretsmanager get-secret-value \
        --secret-id "ec2/test/ssh-private-key" \
        --query SecretString --output text | ssh-add -
    
  • When wireguard is enabled, the wireguard private key is published under a secret which name is stored as the wireguard_private_key_secret instance tag), so playbooks can fetch it without hardcoding the naming scheme:

    terraform_wireguard_private_key: >-
      {{ lookup('amazon.aws.aws_secret', tags.wireguard_private_key_secret) }}
    

The configure stage only needs ec2:Describe* (inventory) and secretsmanager:GetSecretValue scoped to ec2/* (keys).