Skip to content

Resource: awsRedshiftSubnetGroup

Creates a new Amazon Redshift subnet group. You must provide a list of one or more subnets in your existing Amazon Virtual Private Cloud (Amazon VPC) when creating Amazon Redshift subnet group.

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";
const awsVpcFoo = new aws.vpc.Vpc(this, "foo", {
  cidrBlock: "10.1.0.0/16",
});
const awsSubnetBar = new aws.subnet.Subnet(this, "bar", {
  availabilityZone: "us-west-2b",
  cidrBlock: "10.1.2.0/24",
  tags: {
    Name: "tf-dbsubnet-test-2",
  },
  vpcId: awsVpcFoo.id,
});
const awsSubnetFoo = new aws.subnet.Subnet(this, "foo_2", {
  availabilityZone: "us-west-2a",
  cidrBlock: "10.1.1.0/24",
  tags: {
    Name: "tf-dbsubnet-test-1",
  },
  vpcId: awsVpcFoo.id,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsSubnetFoo.overrideLogicalId("foo");
const awsRedshiftSubnetGroupFoo =
  new aws.redshiftSubnetGroup.RedshiftSubnetGroup(this, "foo_3", {
    name: "foo",
    subnetIds: [awsSubnetFoo.id, awsSubnetBar.id],
    tags: {
      environment: "Production",
    },
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsRedshiftSubnetGroupFoo.overrideLogicalId("foo");

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the Redshift Subnet group.
  • description - (Optional) The description of the Redshift Subnet group. Defaults to "Managed by Terraform".
  • subnetIds - (Required) An array 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:

  • arn - Amazon Resource Name (ARN) of the Redshift Subnet group name
  • id - The Redshift Subnet group ID.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Import

Redshift subnet groups can be imported using the name, e.g.,

$ terraform import aws_redshift_subnet_group.testgroup1 test-cluster-subnet-group