Skip to content

Resource: awsDbSubnetGroup

Provides an RDS DB subnet group resource.

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

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.dbSubnetGroup.DbSubnetGroup(this, "default", {
  name: "main",
  subnetIds: ["${aws_subnet.frontend.id}", "${aws_subnet.backend.id}"],
  tags: {
    Name: "My DB subnet group",
  },
});

Argument Reference

The following arguments are supported:

  • name - (Optional, Forces new resource) The name of the DB subnet group. If omitted, Terraform will assign a random, unique name.
  • namePrefix - (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".
  • subnetIds - (Required) A list of VPC subnet IDs.
  • tags - (Optional) A map of tags to assign to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The db subnet group name.
  • arn - The ARN of the db subnet group.
  • supportedNetworkTypes - The network type of the db subnet group.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Import

DB Subnet groups can be imported using the name, e.g.,

$ terraform import aws_db_subnet_group.default production-subnet-group