Reference Real-world modulesMenu

Reference

Tested on real-world modules

Infraglass's own fixtures can only show the patterns we thought to write. To find the rest, it was run on the official examples of the most used AWS modules from terraform-aws-modules, and every result was checked by hand against what each module documents. This page is the record, including what's still imperfect. scripts/realworld-smoke.sh reruns it.

How it was run

  • Only on LocalStack, never a real AWS account. Each example was planned against LocalStack in Docker, with every AWS_* setting cleared, the AWS config and credentials files replaced with empty ones, fake keys, a check that the endpoint is a local LocalStack, and every provider block pinned to LocalStack's account (000000000000). Five were also applied, to get real states.
  • No downloaded code runs. Examples, and modules they download, that run local programs (data "external", local-exec) are skipped before anything runs: the S3 notification example and the IAM role-for-service-accounts example were skipped for this.
  • Checked by hand. For each plan and state, every subnet's classification, route, rule, finding, role link and table setting was compared with the module's own configuration.
Module Version Examples Planned Applied
terraform-aws-vpc v6.9.0 simple, complete, separate-route-tables, network-acls, ipv6-dualstack 5 1
terraform-aws-security-group v6.0.0 complete 1 0
terraform-aws-dynamodb-table v5.5.3 basic, autoscaling, global-tables 3 1 (its resource policy isn't supported by LocalStack's free edition)
terraform-aws-iam v6.11.3 iam-role, iam-policy, iam-user, iam-group, iam-oidc-provider 5 2
terraform-aws-s3-bucket v5.18.0 complete, bucket-policies 2 0 (the apply failed in the emulator)

What held up

  • Loading took 20 to 30 ms per plan, up to 86 resources, and every report format worked.
  • check --fail-on high-finding failed (exit 3) exactly where the examples attach AdministratorAccess and PowerUserAccess, and passed everywhere else.
  • Security group findings appeared only for inbound rules; outbound 0.0.0.0/0 isn't flagged.
  • Trust policies were read correctly: services, accounts, GitHub and CircleCI OIDC, and SAML.
  • DynamoDB keys, indexes, billing, streams, replicas, backups and encryption matched the configurations.

What it found, all fixed

Where What was wrong
Every VPC example, plans No subnets or route tables at all: the module passes the VPC ID through a local, which plans don't include
VPC complete, plans 1,021 links for 80 resources: Terraform lists module.vpc next to module.vpc.vpc_id, and the bare one linked to every resource in the module, inflating blast radius. Now 258
VPC IPv6, plans Database subnets shown as private though their route table sends 0.0.0.0/0 to the internet gateway: the route table is chosen with coalescelist, and the wrong one was picked
VPC separate route tables, plans Database, cache and Redshift subnets attached to the main route table instead of their own
IAM role, plans In a for_each module, every role's attachments went to the first instance's role
VPC complete, plans S3 and DynamoDB gateway endpoints placed in subnets; they have none
VPC simple, state The default network ACL "placed" in every subnet, the VPC shown as using its default security group, the default route table not marked as the main one
DynamoDB global tables, plans A table encrypted with a key created alongside it shown as using an AWS-managed key
IAM policy, IAM role ec2:Describe* and s3:ListAllMyBuckets on "*" flagged, though AWS only allows them on "*"
Security group, plans Variable validations Terraform can only check during apply listed as risks; modules have dozens
S3 complete, plans The default KMS key policy flagged in the resource-policy list, but not on the key
IAM role, CI comment "Gates failed" listed every gate checked, not the ones that failed
VPC complete Endpoint services shortened to the last word (ecr.api shown as api)
Security group, plans A rule whose source isn't known yet shown with an empty source; now (known after apply) or the resource it comes from
VPC network ACLs An IPv6 egress-only route described as "no internet route"; now "outbound IPv6 only"
Graph Long names cut at the end, so private_dns64_nat_gateway[0], [1] and [2] looked identical; zoom was slow with a trackpad pinch and zoomed when scrolling

Each fix has a test. The network, IAM and DynamoDB patterns behind them are now part of the accuracy stack, with hand-written expectations.

Judgement calls, left as they are

  • AWS's own "manage your own MFA" policy (iam-group) gets "Applies to every resource" because it grants iam:GetAccountSummary and similar on "*". Those only work on "*", but Get actions can be sensitive (iam:GetAccountAuthorizationDetails reads all of IAM), so they stay flagged.
  • logs:CreateLogGroup and friends on "*" (iam-user) are flagged: they can be scoped to log groups.
  • Trust from another account (iam-role) is shown, not flagged.

Limits of this test

  • Most examples were only planned, so many IDs were unknown; that's the case it tests hardest.
  • LocalStack emulates AWS. Attribute shapes are the real provider's, but some API behavior differs, and two applies failed in the emulator.
  • One organisation's modules, sixteen examples. Problems with other modules are welcome as wrong or missed result reports.

Improve this page on GitHub · Report a problem