title: How to make a single-AZ (non-HA) RDS instance with terraform?
body: <p>In <a href="https://aws.amazon.com/blogs/database/best-practices-for-converting-a-single-az-amazon-rds-instance-to-a-multi-az-instance/" rel="nofollow noreferrer">this</a> AWS Database Blog, they assert that</p>
  <blockquote>
  <p>You can set up Amazon RDS in a Single-AZ database (DB) instance or a
  Multi-AZ DB instance for high availability requirements</p>
  </blockquote>
  <p>and that you can</p>
  <blockquote>
  <p>...modify existing Single-AZ instances to become Multi-AZ deployments.</p>
  </blockquote>
  <p>Furthermore,</p>
  <blockquote>
  <p>...you can create a Multi-AZ read replica, synchronize it with your
  Single-AZ DB instance, and then promote it as your primary DB instance
  to minimize latencies during conversion.</p>
  </blockquote>
  <p>Additionally, in v1.32 of the official <a href="https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/1.32.0" rel="nofollow noreferrer">AWS VPC Module</a> there are multiple references to the usage of <a href="https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/1.32.0#nat-gateway-scenarios" rel="nofollow noreferrer">single_nat_gateway</a>, particularly</p>
  <blockquote>
  <p>If single_nat_gateway = true, then all private subnets will route
  their Internet traffic through this single NAT gateway.</p>
  </blockquote>
  <p>and in the official RDS module, <code>multi_az</code> is shown as defaulting to <code>false</code> (<a href="https://registry.terraform.io/modules/terraform-aws-modules/rds/aws/latest#input_multi_az" rel="nofollow noreferrer">link</a>).</p>
  <p>Despite this, I am getting the following error</p>
  <pre><code>╷
  │ Error: DBSubnetGroupDoesNotCoverEnoughAZs: The DB subnet group doesn't meet Availability Zone (AZ) coverage requirement. Current AZ coverage: us-west-2a. Add subnets to cover at least 2 AZs.
  │   status code: 400, request id: *****
  │ 
  │   with module.rds.module.db_subnet_group.aws_db_subnet_group.this[0],
  │   on .terraform/modules/rds/modules/db_subnet_group/main.tf line 8, in resource &quot;aws_db_subnet_group&quot; &quot;this&quot;:
  │    8: resource &quot;aws_db_subnet_group&quot; &quot;this&quot; {
  </code></pre>
  <p>when attempting to <code>terraform apply</code> this <code>main.tf</code> configuration:</p>
  <pre><code>module &quot;rds&quot; {
    source                                = &quot;terraform-aws-modules/rds/aws&quot;
    version                               = &quot;~&gt; 3.4.0&quot;
    identifier                            = &quot;${var.env}-${var.user}-${local.db_name}&quot;
    engine                                = var.postgres.engine
    engine_version                        = var.postgres.engine_version
    family                                = var.postgres.family
    major_engine_version                  = var.postgres.major_engine_version
    instance_class                        = var.postgres.instance_class
    allocated_storage                     = var.postgres.allocated_storage
    max_allocated_storage                 = var.postgres.max_allocated_storage
    storage_encrypted                     = var.postgres.storage_encrypted
    password                              = random_password.password.result
    port                                  = var.postgres.port
    multi_az                              = false
    subnet_ids                            = [data.aws_subnet.priv1.id]
    vpc_security_group_ids                = [module.db_security_group.security_group_id]
    maintenance_window                    = var.postgres.maintenance_window
    backup_window                         = var.postgres.backup_window
    enabled_cloudwatch_logs_exports       = var.postgres.enabled_cloudwatch_logs_exports
    backup_retention_period               = var.postgres.backup_retention_period
    skip_final_snapshot                   = var.postgres.skip_final_snapshot
    deletion_protection                   = var.postgres.deletion_protection
    performance_insights_enabled          = var.postgres.performance_insights_enabled
    performance_insights_retention_period = var.postgres.performance_insights_retention_period
    create_monitoring_role                = var.postgres.create_monitoring_role
    monitoring_role_name                  = &quot;${var.env}-${var.user}-${var.postgres.monitoring_role_name}&quot;
    monitoring_interval                   = var.postgres.monitoring_interval
    snapshot_identifier                   = var.postgres.snapshot_identifier
    iam_database_authentication_enabled   = var.postgres.iam_auth
    apply_immediately                     = true
    tags = {
      Name        = &quot;${var.env}-${var.user}-rds&quot;
      Terraform   = &quot;true&quot;
      Environment = var.env
      Created     = timestamp()
    }
  }
  </code></pre>
  <p>with this <code>postgres</code> variable defined in my <code>terraform.tfvars</code>:</p>
  <pre><code>postgres = {
    db_name = &quot;postgres-db&quot;
    # All available versions: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts
    engine                                = &quot;postgres&quot;
    engine_version                        = &quot;11.12&quot;
    family                                = &quot;postgres11&quot; # DB parameter group
    major_engine_version                  = &quot;11&quot;         # DB option group
    instance_class                        = &quot;db.t2.micro&quot;
    allocated_storage                     = 100
    max_allocated_storage                 = 200
    storage_encrypted                     = false
    port                                  = 5432
    multi_az                              = false
    maintenance_window                    = &quot;Mon:00:00-Mon:03:00&quot;
    backup_window                         = &quot;03:00-06:00&quot;
    enabled_cloudwatch_logs_exports       = [&quot;postgresql&quot;, &quot;upgrade&quot;]
    backup_retention_period               = 0
    skip_final_snapshot                   = true
    deletion_protection                   = false
    performance_insights_enabled          = false
    performance_insights_retention_period = 7
    create_monitoring_role                = true
    monitoring_role_name                  = &quot;monitoring_role&quot;
    monitoring_interval                   = 60
    snapshot_identifier                   = &quot;arn:aws:rds:us-west-2:999999999999:snapshot:rds-ss&quot;
    iam_auth                              = true
  }
  </code></pre>
  <p>Similar questions on SO seem to all have answers with the theme that you <em>must</em> provide multiple availability zones, which implies at least two subnets, which - if you are creating them manually as private subnets - would then each need their own NAT gateway.  That seems unnecessarily expensive and constraining, especially for development and test environments.</p>
  <p>How can I deploy a single-az RDS Postgres instance with these components?</p>