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.
What differs
Section titled “What differs”modules/shc/awstakesavailability_zone, aninstance_typeper group and aroot_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_keyandrandom_password, the way page 02 minted the password. aws_iam_user,aws_iam_policy,aws_iam_access_keyandaws_s3_bucketare 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 bydns_provider.shc_config.platformsetsdns.provider,dns.public_addressand the ACME provider in one YAML document, thenshc_repoandshc_deploymentinstall demo apps.- Every platform resource carries
cluster = { ssh = local.app_ssh }instead of a provider-levelsshblock, 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]}Running it
Section titled “Running it”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.
tofu -chdir=learn/shc/terraform/examples/aws-shc inittofu -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.