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

r/aws_redshiftserverless_workgroup: Add max_capacity argument #35720

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
3 changes: 3 additions & 0 deletions .changelog/35720.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_redshiftserverless_workgroup: Add `max_capacity` argument
```
21 changes: 21 additions & 0 deletions internal/service/redshiftserverless/workgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ func ResourceWorkgroup() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
},
"max_capacity": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"namespace_name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -224,6 +229,10 @@ func resourceWorkgroupCreate(ctx context.Context, d *schema.ResourceData, meta i
input.EnhancedVpcRouting = aws.Bool(v.(bool))
}

if v, ok := d.GetOk("max_capacity"); ok {
input.MaxCapacity = aws.Int64(int64(v.(int)))
}

if v, ok := d.GetOk("port"); ok {
input.Port = aws.Int64(int64(v.(int)))
}
Expand Down Expand Up @@ -281,6 +290,7 @@ func resourceWorkgroupRead(ctx context.Context, d *schema.ResourceData, meta int
return sdkdiag.AppendErrorf(diags, "setting endpoint: %s", err)
}
d.Set("enhanced_vpc_routing", out.EnhancedVpcRouting)
d.Set("max_capacity", out.MaxCapacity)
d.Set("namespace_name", out.NamespaceName)
d.Set("port", flattenEndpoint(out.Endpoint)["port"])
d.Set("publicly_accessible", out.PubliclyAccessible)
Expand Down Expand Up @@ -331,6 +341,17 @@ func resourceWorkgroupUpdate(ctx context.Context, d *schema.ResourceData, meta i
}
}

if d.HasChange("max_capacity") {
input := &redshiftserverless.UpdateWorkgroupInput{
MaxCapacity: aws.Int64(int64(d.Get("max_capacity").(int))),
WorkgroupName: aws.String(d.Id()),
}

if err := updateWorkgroup(ctx, conn, input, d.Timeout(schema.TimeoutUpdate)); err != nil {
return sdkdiag.AppendFromErr(diags, err)
}
}

if d.HasChange("port") {
input := &redshiftserverless.UpdateWorkgroupInput{
Port: aws.Int64(int64(d.Get("port").(int))),
Expand Down
15 changes: 9 additions & 6 deletions internal/service/redshiftserverless/workgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestAccRedshiftServerlessWorkgroup_basic(t *testing.T) {
})
}

func TestAccRedshiftServerlessWorkgroup_baseCapacityAndPubliclyAccessible(t *testing.T) {
func TestAccRedshiftServerlessWorkgroup_baseAndMaxCapacityAndPubliclyAccessible(t *testing.T) {
ctx := acctest.Context(t)
resourceName := "aws_redshiftserverless_workgroup.test"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
Expand All @@ -62,10 +62,11 @@ func TestAccRedshiftServerlessWorkgroup_baseCapacityAndPubliclyAccessible(t *tes
CheckDestroy: testAccCheckWorkgroupDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccWorkgroupConfig_baseCapacityAndPubliclyAccessible(rName, 64, true),
Config: testAccWorkgroupConfig_baseAndMaxCapacityAndPubliclyAccessible(rName, 64, 128, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckWorkgroupExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "base_capacity", "64"),
resource.TestCheckResourceAttr(resourceName, "max_capacity", "128"),
resource.TestCheckResourceAttr(resourceName, "publicly_accessible", "true"),
),
},
Expand All @@ -75,10 +76,11 @@ func TestAccRedshiftServerlessWorkgroup_baseCapacityAndPubliclyAccessible(t *tes
ImportStateVerify: true,
},
{
Config: testAccWorkgroupConfig_baseCapacityAndPubliclyAccessible(rName, 128, false),
Config: testAccWorkgroupConfig_baseAndMaxCapacityAndPubliclyAccessible(rName, 128, 5632, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckWorkgroupExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "base_capacity", "128"),
resource.TestCheckResourceAttr(resourceName, "max_capacity", "5632"),
resource.TestCheckResourceAttr(resourceName, "publicly_accessible", "false"),
),
},
Expand Down Expand Up @@ -343,7 +345,7 @@ resource "aws_redshiftserverless_workgroup" "test" {
`, rName)
}

func testAccWorkgroupConfig_baseCapacityAndPubliclyAccessible(rName string, baseCapacity int, publiclyAccessible bool) string {
func testAccWorkgroupConfig_baseAndMaxCapacityAndPubliclyAccessible(rName string, baseCapacity int, maxCapacity int, publiclyAccessible bool) string {
return fmt.Sprintf(`
resource "aws_redshiftserverless_namespace" "test" {
namespace_name = %[1]q
Expand All @@ -353,9 +355,10 @@ resource "aws_redshiftserverless_workgroup" "test" {
namespace_name = aws_redshiftserverless_namespace.test.namespace_name
workgroup_name = %[1]q
base_capacity = %[2]d
publicly_accessible = %[3]t
max_capacity = %[3]d
publicly_accessible = %[4]t
}
`, rName, baseCapacity, publiclyAccessible)
`, rName, baseCapacity, maxCapacity, publiclyAccessible)
}

func testAccWorkgroupConfig_configParameters(rName, maxQueryExecutionTime string) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The following arguments are optional:
* `base_capacity` - (Optional) The base data warehouse capacity of the workgroup in Redshift Processing Units (RPUs).
* `config_parameter` - (Optional) An array of parameters to set for more control over a serverless database. See `Config Parameter` below.
* `enhanced_vpc_routing` - (Optional) The value that specifies whether to turn on enhanced virtual private cloud (VPC) routing, which forces Amazon Redshift Serverless to route traffic through your VPC instead of over the internet.
* `max_capacity` - (Optional) The maximum data-warehouse capacity Amazon Redshift Serverless uses to serve queries, specified in Redshift Processing Units (RPUs).
* `port` - (Optional) The port number on which the cluster accepts incoming connections.
* `publicly_accessible` - (Optional) A value that specifies whether the workgroup can be accessed from a public network.
* `security_group_ids` - (Optional) An array of security group IDs to associate with the workgroup.
Expand Down
Loading