Skip to content

Commit 134c9aa

Browse files
authored
Merge pull request #45258 from catlike/f-aws_eks_cluster-provisioned-control-plane
Add support for EKS Provisioned Control Plane
2 parents 6fe9ab0 + a9ed8e3 commit 134c9aa

File tree

7 files changed

+205
-3
lines changed

7 files changed

+205
-3
lines changed

.changelog/45258.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:enhancement
2+
resource/aws_eks_cluster: Add `control_plane_scaling_config` configuration block to support EKS Provisioned Control Plane
3+
```
4+
5+
```release-note:enhancement
6+
data-source/aws_eks_cluster: Add `control_plane_scaling_config` attribute
7+
```

internal/service/eks/cluster.go

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,22 @@ func resourceCluster() *schema.Resource {
143143
},
144144
},
145145
},
146+
"control_plane_scaling_config": {
147+
Type: schema.TypeList,
148+
Optional: true,
149+
Computed: true,
150+
MaxItems: 1,
151+
Elem: &schema.Resource{
152+
Schema: map[string]*schema.Schema{
153+
"tier": {
154+
Type: schema.TypeString,
155+
Optional: true,
156+
Computed: true,
157+
ValidateDiagFunc: enum.Validate[types.ProvisionedControlPlaneTier](),
158+
},
159+
},
160+
},
161+
},
146162
names.AttrCreatedAt: {
147163
Type: schema.TypeString,
148164
Computed: true,
@@ -510,6 +526,10 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta any
510526
input.AccessConfig = expandCreateAccessConfigRequest(v.([]any))
511527
}
512528

529+
if v, ok := d.GetOk("control_plane_scaling_config"); ok {
530+
input.ControlPlaneScalingConfig = expandControlPlaneScalingConfig(v.([]any))
531+
}
532+
513533
if v, ok := d.GetOk(names.AttrDeletionProtection); ok {
514534
input.DeletionProtection = aws.Bool(v.(bool))
515535
}
@@ -619,6 +639,9 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta any)
619639
if err := d.Set("compute_config", flattenComputeConfigResponse(cluster.ComputeConfig)); err != nil {
620640
return sdkdiag.AppendErrorf(diags, "setting compute_config: %s", err)
621641
}
642+
if err := d.Set("control_plane_scaling_config", flattenControlPlaneScalingConfig(cluster.ControlPlaneScalingConfig)); err != nil {
643+
return sdkdiag.AppendErrorf(diags, "setting control_plane_scaling_config: %s", err)
644+
}
622645
d.Set(names.AttrCreatedAt, cluster.CreatedAt.Format(time.RFC3339))
623646
d.Set(names.AttrDeletionProtection, cluster.DeletionProtection)
624647
if err := d.Set("enabled_cluster_log_types", flattenLogging(cluster.Logging)); err != nil {
@@ -739,6 +762,25 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta any
739762
}
740763
}
741764

765+
if d.HasChange("control_plane_scaling_config") {
766+
input := eks.UpdateClusterConfigInput{
767+
ControlPlaneScalingConfig: expandControlPlaneScalingConfig(d.Get("control_plane_scaling_config").([]any)),
768+
Name: aws.String(d.Id()),
769+
}
770+
771+
output, err := conn.UpdateClusterConfig(ctx, &input)
772+
773+
if err != nil {
774+
return sdkdiag.AppendErrorf(diags, "updating EKS Cluster (%s) control plane scaling config: %s", d.Id(), err)
775+
}
776+
777+
updateID := aws.ToString(output.Update.Id)
778+
779+
if _, err := waitClusterUpdateSuccessful(ctx, conn, d.Id(), updateID, d.Timeout(schema.TimeoutUpdate)); err != nil {
780+
return sdkdiag.AppendErrorf(diags, "waiting for EKS Cluster (%s) control plane scaling config update (%s): %s", d.Id(), updateID, err)
781+
}
782+
}
783+
742784
if d.HasChange(names.AttrDeletionProtection) {
743785
if err := updateClusterDeletionProtection(ctx, conn, d.Id(), d.Get(names.AttrDeletionProtection).(bool), d.Timeout(schema.TimeoutUpdate)); err != nil {
744786
return sdkdiag.AppendFromErr(diags, err)
@@ -761,7 +803,7 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta any
761803
updateID := aws.ToString(output.Update.Id)
762804

763805
if _, err := waitClusterUpdateSuccessful(ctx, conn, d.Id(), updateID, d.Timeout(schema.TimeoutUpdate)); err != nil {
764-
return sdkdiag.AppendErrorf(diags, "waiting for EKS Cluster (%s) encryption config association (%s): %s", d.Id(), updateID, err)
806+
return sdkdiag.AppendErrorf(diags, "waiting for EKS Cluster (%s) encryption config update (%s): %s", d.Id(), updateID, err)
765807
}
766808
}
767809
}
@@ -1197,6 +1239,25 @@ func expandComputeConfigRequest(tfList []any) *types.ComputeConfigRequest {
11971239
return apiObject
11981240
}
11991241

1242+
func expandControlPlaneScalingConfig(tfList []any) *types.ControlPlaneScalingConfig {
1243+
if len(tfList) == 0 {
1244+
return nil
1245+
}
1246+
1247+
tfMap, ok := tfList[0].(map[string]any)
1248+
if !ok {
1249+
return nil
1250+
}
1251+
1252+
apiObject := &types.ControlPlaneScalingConfig{}
1253+
1254+
if v, ok := tfMap["tier"].(string); ok && v != "" {
1255+
apiObject.Tier = types.ProvisionedControlPlaneTier(v)
1256+
}
1257+
1258+
return apiObject
1259+
}
1260+
12001261
func expandEncryptionConfig(tfList []any) []types.EncryptionConfig {
12011262
if len(tfList) == 0 {
12021263
return nil
@@ -1585,6 +1646,18 @@ func flattenComputeConfigResponse(apiObject *types.ComputeConfigResponse) []map[
15851646
return []map[string]any{tfMap}
15861647
}
15871648

1649+
func flattenControlPlaneScalingConfig(apiObject *types.ControlPlaneScalingConfig) []any {
1650+
if apiObject == nil {
1651+
return nil
1652+
}
1653+
1654+
tfMap := map[string]any{
1655+
"tier": apiObject.Tier,
1656+
}
1657+
1658+
return []any{tfMap}
1659+
}
1660+
15881661
func flattenIdentity(apiObject *types.Identity) []map[string]any {
15891662
if apiObject == nil {
15901663
return []map[string]any{}

internal/service/eks/cluster_data_source.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ func dataSourceCluster() *schema.Resource {
8181
},
8282
},
8383
},
84+
"control_plane_scaling_config": {
85+
Type: schema.TypeList,
86+
Computed: true,
87+
Elem: &schema.Resource{
88+
Schema: map[string]*schema.Schema{
89+
"tier": {
90+
Type: schema.TypeString,
91+
Computed: true,
92+
},
93+
},
94+
},
95+
},
8496
names.AttrCreatedAt: {
8597
Type: schema.TypeString,
8698
Computed: true,
@@ -350,6 +362,9 @@ func dataSourceClusterRead(ctx context.Context, d *schema.ResourceData, meta any
350362
if err := d.Set("compute_config", flattenComputeConfigResponse(cluster.ComputeConfig)); err != nil {
351363
return sdkdiag.AppendErrorf(diags, "setting compute_config: %s", err)
352364
}
365+
if err := d.Set("control_plane_scaling_config", flattenControlPlaneScalingConfig(cluster.ControlPlaneScalingConfig)); err != nil {
366+
return sdkdiag.AppendErrorf(diags, "setting control_plane_scaling_config: %s", err)
367+
}
353368
d.Set(names.AttrCreatedAt, cluster.CreatedAt.Format(time.RFC3339))
354369
d.Set(names.AttrDeletionProtection, cluster.DeletionProtection)
355370
if err := d.Set("enabled_cluster_log_types", flattenLogging(cluster.Logging)); err != nil {

internal/service/eks/cluster_data_source_test.go

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ func TestAccEKSClusterDataSource_basic(t *testing.T) {
3333
resource.TestCheckResourceAttr(dataSourceResourceName, "certificate_authority.#", "1"),
3434
resource.TestCheckResourceAttrPair(resourceName, "certificate_authority.0.data", dataSourceResourceName, "certificate_authority.0.data"),
3535
resource.TestCheckNoResourceAttr(dataSourceResourceName, "cluster_id"),
36-
resource.TestCheckResourceAttr(resourceName, "compute_config.#", "0"),
36+
resource.TestCheckResourceAttr(resourceName, "compute_config.#", "1"),
37+
resource.TestCheckResourceAttr(dataSourceResourceName, "control_plane_scaling_config.#", "1"),
38+
resource.TestCheckResourceAttrPair(resourceName, "control_plane_scaling_config.0.tier", dataSourceResourceName, "control_plane_scaling_config.0.tier"),
39+
resource.TestCheckResourceAttr(dataSourceResourceName, "control_plane_scaling_config.0.tier", "standard"),
3740
resource.TestCheckResourceAttrPair(resourceName, names.AttrCreatedAt, dataSourceResourceName, names.AttrCreatedAt),
3841
resource.TestCheckResourceAttrPair(resourceName, names.AttrDeletionProtection, dataSourceResourceName, names.AttrDeletionProtection),
3942
resource.TestCheckResourceAttr(dataSourceResourceName, "enabled_cluster_log_types.#", "2"),
@@ -53,7 +56,7 @@ func TestAccEKSClusterDataSource_basic(t *testing.T) {
5356
resource.TestCheckResourceAttr(dataSourceResourceName, "remote_network_config.#", "0"),
5457
resource.TestCheckResourceAttrPair(resourceName, names.AttrRoleARN, dataSourceResourceName, names.AttrRoleARN),
5558
resource.TestCheckResourceAttrPair(resourceName, names.AttrStatus, dataSourceResourceName, names.AttrStatus),
56-
resource.TestCheckResourceAttr(resourceName, "storage_config.#", "0"),
59+
resource.TestCheckResourceAttr(resourceName, "storage_config.#", "1"),
5760
resource.TestCheckResourceAttrPair(resourceName, acctest.CtTagsPercent, dataSourceResourceName, acctest.CtTagsPercent),
5861
resource.TestCheckResourceAttr(resourceName, "upgrade_policy.#", "1"),
5962
resource.TestCheckResourceAttr(resourceName, "upgrade_policy.0.support_type", "EXTENDED"),
@@ -183,6 +186,33 @@ func TestAccEKSClusterDataSource_remoteNetwork(t *testing.T) {
183186
})
184187
}
185188

189+
func TestAccEKSClusterDataSource_controlPlaneScalingConfig(t *testing.T) {
190+
ctx := acctest.Context(t)
191+
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
192+
dataSourceResourceName := "data.aws_eks_cluster.test"
193+
resourceName := "aws_eks_cluster.test"
194+
195+
resource.ParallelTest(t, resource.TestCase{
196+
PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) },
197+
ErrorCheck: acctest.ErrorCheck(t, names.EKSServiceID),
198+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
199+
CheckDestroy: testAccCheckClusterDestroy(ctx),
200+
Steps: []resource.TestStep{
201+
{
202+
Config: testAccClusterDataSourceConfig_controlPlaneScalingConfig(rName, "tier-xl"),
203+
Check: resource.ComposeTestCheckFunc(
204+
resource.TestCheckResourceAttrPair(resourceName, names.AttrARN, dataSourceResourceName, names.AttrARN),
205+
resource.TestCheckResourceAttr(dataSourceResourceName, "control_plane_scaling_config.#", "1"),
206+
resource.TestCheckResourceAttrPair(resourceName, "control_plane_scaling_config.0.tier", dataSourceResourceName, "control_plane_scaling_config.0.tier"),
207+
resource.TestCheckResourceAttr(dataSourceResourceName, "control_plane_scaling_config.0.tier", "tier-xl"),
208+
resource.TestCheckResourceAttrPair(resourceName, names.AttrName, dataSourceResourceName, names.AttrName),
209+
resource.TestCheckResourceAttrPair(resourceName, names.AttrStatus, dataSourceResourceName, names.AttrStatus),
210+
),
211+
},
212+
},
213+
})
214+
}
215+
186216
func testAccClusterDataSourceConfig_basic(rName string) string {
187217
return acctest.ConfigCompose(testAccClusterConfig_logging(rName, []string{"api", "audit"}), `
188218
data "aws_eks_cluster" "test" {
@@ -206,3 +236,11 @@ data "aws_eks_cluster" "test" {
206236
}
207237
`)
208238
}
239+
240+
func testAccClusterDataSourceConfig_controlPlaneScalingConfig(rName, tier string) string {
241+
return acctest.ConfigCompose(testAccClusterConfig_controlPlaneScalingConfig(rName, tier), `
242+
data "aws_eks_cluster" "test" {
243+
name = aws_eks_cluster.test.name
244+
}
245+
`)
246+
}

internal/service/eks/cluster_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ func TestAccEKSCluster_basic(t *testing.T) {
6767
resource.TestCheckResourceAttrSet(resourceName, "certificate_authority.0.data"),
6868
resource.TestCheckNoResourceAttr(resourceName, "cluster_id"),
6969
resource.TestCheckResourceAttr(resourceName, "compute_config.#", "1"),
70+
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.#", "1"),
71+
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.0.tier", "standard"),
7072
acctest.CheckResourceAttrRFC3339(resourceName, names.AttrCreatedAt),
7173
resource.TestCheckResourceAttr(resourceName, names.AttrDeletionProtection, acctest.CtFalse),
7274
resource.TestCheckResourceAttr(resourceName, "enabled_cluster_log_types.#", "0"),
@@ -626,6 +628,45 @@ func TestAccEKSCluster_ComputeConfig_AddARN(t *testing.T) {
626628
})
627629
}
628630

631+
func TestAccEKSCluster_controlPlaneScalingConfig(t *testing.T) {
632+
ctx := acctest.Context(t)
633+
var cluster1, cluster2 types.Cluster
634+
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
635+
resourceName := "aws_eks_cluster.test"
636+
637+
resource.ParallelTest(t, resource.TestCase{
638+
PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) },
639+
ErrorCheck: acctest.ErrorCheck(t, names.EKSServiceID),
640+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
641+
CheckDestroy: testAccCheckClusterDestroy(ctx),
642+
Steps: []resource.TestStep{
643+
{
644+
Config: testAccClusterConfig_controlPlaneScalingConfig(rName, "tier-xl"),
645+
Check: resource.ComposeAggregateTestCheckFunc(
646+
testAccCheckClusterExists(ctx, resourceName, &cluster1),
647+
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.#", "1"),
648+
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.0.tier", "tier-xl"),
649+
),
650+
},
651+
{
652+
ResourceName: resourceName,
653+
ImportState: true,
654+
ImportStateVerify: true,
655+
ImportStateVerifyIgnore: []string{"bootstrap_self_managed_addons"},
656+
},
657+
{
658+
Config: testAccClusterConfig_controlPlaneScalingConfig(rName, "standard"),
659+
Check: resource.ComposeAggregateTestCheckFunc(
660+
testAccCheckClusterExists(ctx, resourceName, &cluster2),
661+
testAccCheckClusterNotRecreated(&cluster1, &cluster2),
662+
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.#", "1"),
663+
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.0.tier", "standard"),
664+
),
665+
},
666+
},
667+
})
668+
}
669+
629670
func TestAccEKSCluster_Encryption_create(t *testing.T) {
630671
ctx := acctest.Context(t)
631672
var cluster types.Cluster
@@ -2647,3 +2688,22 @@ resource "aws_eks_cluster" "test" {
26472688
}
26482689
`, rName, deletionProtection))
26492690
}
2691+
2692+
func testAccClusterConfig_controlPlaneScalingConfig(rName, tier string) string {
2693+
return acctest.ConfigCompose(testAccClusterConfig_base(rName), fmt.Sprintf(`
2694+
resource "aws_eks_cluster" "test" {
2695+
name = %[1]q
2696+
role_arn = aws_iam_role.cluster.arn
2697+
2698+
vpc_config {
2699+
subnet_ids = aws_subnet.test[*].id
2700+
}
2701+
2702+
control_plane_scaling_config {
2703+
tier = %[2]q
2704+
}
2705+
2706+
depends_on = [aws_iam_role_policy_attachment.cluster_AmazonEKSClusterPolicy]
2707+
}
2708+
`, rName, tier))
2709+
}

website/docs/d/eks_cluster.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ This data source exports the following attributes in addition to the arguments a
4646
* `enabled` - Whether the EKS Auto Mode compute capability is enabled or not.
4747
* `node_pools` - List of node pools for the EKS Auto Mode compute capability.
4848
* `node_role_arn` - The ARN of the IAM Role EKS will assign to EC2 Managed Instances in your EKS Auto Mode cluster.
49+
* `control_plane_scaling_config` - Configuration block for the control plane scaling tier. See [EKS Provisioned Control Plane](https://docs.aws.amazon.com/eks/latest/userguide/eks-provisioned-control-plane-getting-started.html) for more information.
50+
* `tier` - The control plane scaling tier. Valid values are `standard`, `tier-xl`, `tier-2xl`, or `tier-4xl`.
4951
* `certificate_authority` - Nested attribute containing `certificate-authority-data` for your cluster.
5052
* `data` - The base64 encoded certificate data required to communicate with your cluster. Add this to the `certificate-authority-data` section of the `kubeconfig` file for your cluster.
5153
* `cluster_id` - The ID of your local Amazon EKS cluster on the AWS Outpost. This attribute isn't available for an AWS EKS cluster on AWS cloud.

website/docs/r/eks_cluster.html.markdown

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ The following arguments are optional:
347347
* `access_config` - (Optional) Configuration block for the access config associated with your cluster, see [Amazon EKS Access Entries](https://docs.aws.amazon.com/eks/latest/userguide/access-entries.html). [Detailed](#access_config) below.
348348
* `bootstrap_self_managed_addons` - (Optional) Install default unmanaged add-ons, such as `aws-cni`, `kube-proxy`, and CoreDNS during cluster creation. If `false`, you must manually install desired add-ons. Changing this value will force a new cluster to be created. Defaults to `true`.
349349
* `compute_config` - (Optional) Configuration block with compute configuration for EKS Auto Mode. [Detailed](#compute_config) below.
350+
* `control_plane_scaling_config` - (Optional) Configuration block for the control plane scaling tier. See [EKS Provisioned Control Plane](https://docs.aws.amazon.com/eks/latest/userguide/eks-provisioned-control-plane-getting-started.html) for more information. [Detailed](#control_plane_scaling_config) below.
350351
* `deletion_protection` - (Optional) Whether to enable deletion protection for the cluster. When enabled, the cluster cannot be deleted unless deletion protection is first disabled. Default: `false`.
351352
* `enabled_cluster_log_types` - (Optional) List of the desired control plane logging to enable. For more information, see [Amazon EKS Control Plane Logging](https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html).
352353
* `encryption_config` - (Optional) Configuration block with encryption configuration for the cluster. [Detailed](#encryption_config) below.
@@ -376,6 +377,12 @@ The `compute_config` configuration block supports the following arguments:
376377
* `node_pools` - (Optional) Configuration for node pools that defines the compute resources for your EKS Auto Mode cluster. Valid options are `general-purpose` and `system`.
377378
* `node_role_arn` - (Optional) The ARN of the IAM Role EKS will assign to EC2 Managed Instances in your EKS Auto Mode cluster. This value cannot be changed after the compute capability of EKS Auto Mode is enabled..
378379

380+
### control_plane_scaling_config
381+
382+
The `control_plane_scaling_config` configuration block supports the following arguments:
383+
384+
* `tier` - (Optional) The control plane scaling tier. Valid values are `standard`, `tier-xl`, `tier-2xl`, or `tier-4xl`. Defaults to `standard`. For more information about each tier, see [EKS Provisioned Control Plane](https://docs.aws.amazon.com/eks/latest/userguide/eks-provisioned-control-plane-getting-started.html).
385+
379386
### encryption_config
380387

381388
The `encryption_config` configuration block supports the following arguments:

0 commit comments

Comments
 (0)