Skip to main content
Dev · 283 tools

Mock Terraform Resource Generator

Generates example Terraform resource blocks for learning and testing

Terraform ResourceExample — click Generate for yours
resource "aws_cloudwatch_event_rule" "routing_api_sweep" { name = "routing-api-refresh" description = "Triggers routing-api on cron(28 23 * * ? *)" schedule_expression = "cron(28 23 * * ? *)" state = "ENABLED" tags = { Name = "routing-api-rule" Environment = var.environment CostCenter = "CC-4696" } }

Generated 43 words · 371 characters

See 3 examples
  • Example 1
    resource "aws_cloudwatch_event_rule" "routing_api_sweep" {
      name                = "routing-api-refresh"
      description         = "Triggers routing-api on cron(28 23 * * ? *)"
      schedule_expression = "cron(28 23 * * ? *)"
      state               = "ENABLED"
    
      tags = {
        Name        = "routing-api-rule"
        Environment = var.environment
        CostCenter  = "CC-4696"
      }
    }
  • Example 2
    resource "aws_cloudwatch_log_group" "reports_processor" {
      name              = "/ecs/reports-processor"
      retention_in_days = 30
    
      tags = {
        Name        = "reports-processor-logs"
        Environment = var.environment
        CostCenter  = "CC-8853"
      }
    }
  • Example 3
    resource "aws_lb_target_group" "identity_processor" {
      name                 = "identity-processor-tg"
      port                 = 4000
      protocol             = "HTTP"
      target_type          = "instance"
      vpc_id               = "vpc-0caeebc4923ed6f51"
      deregistration_delay = 300
    
      health_check {
        path                = "/ping"
        matcher             = "200"
        interval            = 20
        timeout             = 5
        healthy_threshold   = 5
        unhealthy_threshold = 4
      }
    
      tags = {
        Name        = "identity-processor-tg"
        Environment = var.environment
        CostCenter  = "CC-1549"
      }
    }

About this generator

Reading Terraform documentation is one thing; seeing a complete, working resource block you can study and adapt is faster for learning HCL structure. This tool generates one of 39 AWS resource patterns at random — S3 buckets with versioning, EC2 instances, security groups, RDS and Aurora databases, IAM roles and policies with their policy documents, Lambda functions, DynamoDB tables, SQS queues, SNS topics, VPCs and subnets, load balancers, ECS services, CloudWatch alarms, and more — each with the correct HCL syntax: resource type and name, arguments, tags, and nested blocks where needed, aligned the way terraform fmt would align them. There are no inputs — click Generate to get a different resource each time. Names, sizes, versions, ports, and settings vary from click to click, and related resources reference each other the way real configurations do (a versioning block points at its bucket, a role reads its trust policy from a data source). Every resource carries a tags block with Name, Environment, and CostCenter. Database blocks reference var.db_password or let AWS manage the master password instead of hard-coding a secret. Copy the output into a .tf file to study the syntax or scaffold a starting point. Replace placeholder values with variables and real names before applying to any environment. Store secrets in a secrets manager and reference them via a Terraform data source rather than embedding them in source files.

How to use

  1. Click Generate to produce a resource block.
  2. Copy the HCL into a file or doc.
  3. Adapt the names and arguments.
  4. Keep real secrets out of the file.

Use Cases

  • •Learning Terraform and HCL
  • •Documenting infrastructure
  • •Demoing resource structure
  • •Seeding example config
  • •Testing an HCL parser

Tips

  • →Never commit real secrets to HCL.
  • →Use variables and a secrets manager.
  • →Adapt resource names to your infra.
  • →Use it to learn HCL structure.

FAQ

what resource types can the generator produce

It picks one of 39 patterns at random, covering about 40 resource types: aws_s3_bucket (with aws_s3_bucket_versioning), aws_instance, aws_security_group, aws_db_instance, aws_rds_cluster, aws_iam_role and aws_iam_policy (with an aws_iam_policy_document data source), aws_lambda_function, aws_dynamodb_table, aws_sqs_queue, aws_sns_topic, aws_vpc and aws_subnet, aws_lb and aws_lb_target_group, aws_ecs_cluster and aws_ecs_service, aws_cloudwatch_metric_alarm, aws_kms_key, aws_secretsmanager_secret, aws_route53_record, and more. There is no way to request a specific type — keep clicking Generate to see them all.

what is a terraform resource block

A resource block declares a piece of infrastructure Terraform will create and manage. It starts with the keyword resource, then the provider resource type (e.g. aws_s3_bucket), then a local name you reference elsewhere in the config. The body contains arguments specific to that resource type.

is it safe to put a password directly in a terraform file

No. The generated database blocks reference a variable (var.db_password) or set manage_master_user_password so AWS keeps the secret, and you should never commit a real secret to a .tf file. Use a Terraform variable marked sensitive and supply the value from an environment variable or a secrets manager, and ensure your state file is stored securely — it can contain secret values in plaintext.

what is the difference between a resource and a data source in terraform

A resource block creates and manages infrastructure that Terraform owns; destroying the resource destroys the real thing. A data source only reads existing infrastructure or values to reference elsewhere and never creates or destroys anything. The generator produces resource blocks; data sources use a 'data' block instead.

You might also like

Popular tools from other categories that share themes with this one.