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.
resource "aws_db_subnet_group" "default" {
name = "main"
subnet_ids = [aws_subnet.frontend.id, aws_subnet.backend.id]
tags = {
Name = "My DB subnet group"
}
}
This resource supports the following arguments:
name
- (Optional, Forces new resource) The name of the DB subnet group. If omitted, Terraform will assign a random, unique name.name_prefix
- (Optional, Forces new resource) Creates a unique name beginning with the specified prefix. Conflicts with name
.description
- (Optional) The description of the DB subnet group. Defaults to "Managed by Terraform".subnet_ids
- (Required) A list of VPC subnet IDs.tags
- (Optional) A map of tags to assign to the resource. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.This resource exports the following attributes in addition to the arguments above:
id
- The db subnet group name.arn
- The ARN of the db subnet group.supported_network_types
- The network type of the db subnet group.tags_all
- A map of tags assigned to the resource, including those inherited from the provider default_tags
configuration block.vpc_id
- Provides the VPC ID of the DB subnet group.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