Resource: aws_db_subnet_group

Provides an RDS DB subnet group resource.

Hands-on: For an example of the aws_db_subnet_group in use, follow the Manage AWS RDS Instances tutorial on HashiCorp Learn.

Example Usage

resource "aws_db_subnet_group" "default" {
  name       = "main"
  subnet_ids = [aws_subnet.frontend.id, aws_subnet.backend.id]

  tags = {
    Name = "My DB subnet group"
  }
}

Argument Reference

This resource supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import DB Subnet groups using the name. For example:

import {
  to = aws_db_subnet_group.default
  id = "production-subnet-group"
}

Using terraform import, import DB Subnet groups using the name. For example:

% terraform import aws_db_subnet_group.default production-subnet-group