Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add argument cluster_namespace_arn to aws_redshift_cluster #31884

Merged
merged 4 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/31884.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_redshift_cluster: Add `cluster_namespace_arn` attribute
```

```release-note:enhancement
data-source/aws_redshift_cluster: Add `cluster_namespace_arn` attribute
```
5 changes: 5 additions & 0 deletions internal/service/redshift/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ func ResourceCluster() *schema.Resource {
validation.StringDoesNotMatch(regexp.MustCompile(`-$`), "cannot end with a hyphen"),
),
},
"cluster_namespace_arn": {
Type: schema.TypeString,
Computed: true,
},
"cluster_nodes": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -608,6 +612,7 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter
}
d.Set("availability_zone_relocation_enabled", azr)
d.Set("cluster_identifier", rsc.ClusterIdentifier)
d.Set("cluster_namespace_arn", rsc.ClusterNamespaceArn)
if err := d.Set("cluster_nodes", flattenClusterNodes(rsc.ClusterNodes)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting cluster_nodes: %s", err)
}
Expand Down
13 changes: 5 additions & 8 deletions internal/service/redshift/cluster_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func DataSourceCluster() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
"cluster_namespace_arn": {
Type: schema.TypeString,
Computed: true,
},
"cluster_nodes": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -226,38 +230,31 @@ func dataSourceClusterRead(ctx context.Context, d *schema.ResourceData, meta int
}
d.Set("availability_zone_relocation_enabled", azr)
d.Set("cluster_identifier", rsc.ClusterIdentifier)
d.Set("cluster_namespace_arn", rsc.ClusterNamespaceArn)
if err := d.Set("cluster_nodes", flattenClusterNodes(rsc.ClusterNodes)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting cluster_nodes: %s", err)
}

if len(rsc.ClusterParameterGroups) > 0 {
d.Set("cluster_parameter_group_name", rsc.ClusterParameterGroups[0].ParameterGroupName)
}

d.Set("cluster_public_key", rsc.ClusterPublicKey)
d.Set("cluster_revision_number", rsc.ClusterRevisionNumber)
d.Set("cluster_subnet_group_name", rsc.ClusterSubnetGroupName)

if len(rsc.ClusterNodes) > 1 {
d.Set("cluster_type", clusterTypeMultiNode)
} else {
d.Set("cluster_type", clusterTypeSingleNode)
}

d.Set("cluster_version", rsc.ClusterVersion)
d.Set("database_name", rsc.DBName)

if rsc.ElasticIpStatus != nil {
d.Set("elastic_ip", rsc.ElasticIpStatus.ElasticIp)
}

d.Set("encrypted", rsc.Encrypted)

if rsc.Endpoint != nil {
d.Set("endpoint", rsc.Endpoint.Address)
d.Set("port", rsc.Endpoint.Port)
}

d.Set("enhanced_vpc_routing", rsc.EnhancedVpcRouting)

var iamRoles []string
Expand Down
1 change: 1 addition & 0 deletions internal/service/redshift/cluster_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestAccRedshiftClusterDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(dataSourceName, "automated_snapshot_retention_period"),
resource.TestCheckResourceAttrSet(dataSourceName, "availability_zone"),
resource.TestCheckResourceAttrSet(dataSourceName, "cluster_identifier"),
resource.TestCheckResourceAttrPair(dataSourceName, "cluster_namespace_arn", resourceName, "cluster_namespace_arn"),
resource.TestCheckResourceAttrSet(dataSourceName, "cluster_parameter_group_name"),
resource.TestCheckResourceAttrSet(dataSourceName, "cluster_public_key"),
resource.TestCheckResourceAttrSet(dataSourceName, "cluster_revision_number"),
Expand Down
3 changes: 2 additions & 1 deletion website/docs/d/redshift_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ In addition to all arguments above, the following attributes are exported:
* `cluster_revision_number` - The cluster revision number
* `cluster_subnet_group_name` - The name of a cluster subnet group to be associated with this cluster
* `cluster_type` - Cluster type
* `cluster_namespace_arn` - The namespace Amazon Resource Name (ARN) of the cluster
* `database_name` - Name of the default database in the cluster
* `default_iam_role_arn` - The ARN for the IAM role that was set as default for the cluster when the cluster was created.
* `default_iam_role_arn` - The ARN for the IAM role that was set as default for the cluster when the cluster was created.
* `elastic_ip` - Elastic IP of the cluster
* `enable_logging` - Whether cluster logging is enabled
* `encrypted` - Whether the cluster data is encrypted
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/redshift_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ In addition to all arguments above, the following attributes are exported:
* `cluster_public_key` - The public key for the cluster
* `cluster_revision_number` - The specific revision number of the database in the cluster
* `cluster_nodes` - The nodes in the cluster. Cluster node blocks are documented below
* `cluster_namespace_arn` - The namespace Amazon Resource Name (ARN) of the cluster
* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block).

Cluster nodes (for `cluster_nodes`) support the following attributes:
Expand Down