Skip to content
SHC Docs

Example: aws-shc

terraform/examples/aws-shc mirrors a live AWS estate. Beside the cluster it creates what the daemon needs to act on AWS for you: an IAM user with a scoped policy, its access key, and an S3 bucket for backups. The cluster then gets an aws connection built from those, and the platform is wired with root-level resources rather than the module’s topology.

  • modules/shc/aws takes availability_zone, an instance_type per group and a root_volume. The module source is a published tarball, not the checkout.
  • The key pair and the vault password are minted in the root with tls_private_key and random_password, the way page 02 minted the password.
  • aws_iam_user, aws_iam_policy, aws_iam_access_key and aws_s3_bucket are plain AWS resources; shc_connection "aws" carries their output into the cluster. DNS is Route53 through the same connection or Cloudflare through a second one, chosen by dns_provider.
  • shc_config.platform sets dns.provider, dns.public_address and the ACME provider in one YAML document, then shc_repo and shc_deployment install demo apps.
  • Every platform resource carries cluster = { ssh = local.app_ssh } instead of a provider-level ssh block, the per-resource form.
resource "shc_connection" "aws" {
name = "aws"
type = "aws"
credentials = {
access_key = aws_iam_access_key.shc_daemon.id
secret_key = aws_iam_access_key.shc_daemon.secret
region = var.region
vpc_id = module.shc.vpc_id
subnets = module.shc.subnet_id
availability_zone = module.shc.availability_zone
volume_type = "gp3"
}
cluster = { ssh = local.app_ssh }
depends_on = [module.shc, aws_iam_user_policy_attachment.shc_daemon]
}

AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY for an administrator, and TF_VAR_dns_token for Cloudflare, come from the environment. cluster_name, dns_zone, shc_host and acme_email go on the command line or in a tfvars. It needs OpenTofu 1.8 or newer.

Terminal window
tofu -chdir=learn/shc/terraform/examples/aws-shc init
tofu -chdir=learn/shc/terraform/examples/aws-shc apply -var cluster_name=demo -var dns_zone=example.com -var shc_host=cloud.example.com -var [email protected]
tofu -chdir=learn/shc/terraform/examples/aws-shc destroy -var cluster_name=demo -var dns_zone=example.com -var shc_host=cloud.example.com -var [email protected]

This page was not walked: no AWS credential is on the learning workstation. Track F’s AWS page covers the same account through the CLI.

Next: Example: azure-shc.