Skip to content
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/45258.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_eks_cluster: Add `control_plane_scaling_config` configuration block to support EKS Provisioned Control Plane
```

```release-note:enhancement
data-source/aws_eks_cluster: Add `control_plane_scaling_config` attribute
```
75 changes: 74 additions & 1 deletion internal/service/eks/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,22 @@ func resourceCluster() *schema.Resource {
},
},
},
"control_plane_scaling_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"tier": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateDiagFunc: enum.Validate[types.ProvisionedControlPlaneTier](),
},
},
},
},
names.AttrCreatedAt: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -510,6 +526,10 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta any
input.AccessConfig = expandCreateAccessConfigRequest(v.([]any))
}

if v, ok := d.GetOk("control_plane_scaling_config"); ok {
input.ControlPlaneScalingConfig = expandControlPlaneScalingConfig(v.([]any))
}

if v, ok := d.GetOk(names.AttrDeletionProtection); ok {
input.DeletionProtection = aws.Bool(v.(bool))
}
Expand Down Expand Up @@ -619,6 +639,9 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta any)
if err := d.Set("compute_config", flattenComputeConfigResponse(cluster.ComputeConfig)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting compute_config: %s", err)
}
if err := d.Set("control_plane_scaling_config", flattenControlPlaneScalingConfig(cluster.ControlPlaneScalingConfig)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting control_plane_scaling_config: %s", err)
}
d.Set(names.AttrCreatedAt, cluster.CreatedAt.Format(time.RFC3339))
d.Set(names.AttrDeletionProtection, cluster.DeletionProtection)
if err := d.Set("enabled_cluster_log_types", flattenLogging(cluster.Logging)); err != nil {
Expand Down Expand Up @@ -739,6 +762,25 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta any
}
}

if d.HasChange("control_plane_scaling_config") {
input := eks.UpdateClusterConfigInput{
ControlPlaneScalingConfig: expandControlPlaneScalingConfig(d.Get("control_plane_scaling_config").([]any)),
Name: aws.String(d.Id()),
}

output, err := conn.UpdateClusterConfig(ctx, &input)

if err != nil {
return sdkdiag.AppendErrorf(diags, "updating EKS Cluster (%s) control plane scaling config: %s", d.Id(), err)
}

updateID := aws.ToString(output.Update.Id)

if _, err := waitClusterUpdateSuccessful(ctx, conn, d.Id(), updateID, d.Timeout(schema.TimeoutUpdate)); err != nil {
return sdkdiag.AppendErrorf(diags, "waiting for EKS Cluster (%s) control plane scaling config update (%s): %s", d.Id(), updateID, err)
}
}

if d.HasChange(names.AttrDeletionProtection) {
if err := updateClusterDeletionProtection(ctx, conn, d.Id(), d.Get(names.AttrDeletionProtection).(bool), d.Timeout(schema.TimeoutUpdate)); err != nil {
return sdkdiag.AppendFromErr(diags, err)
Expand All @@ -761,7 +803,7 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta any
updateID := aws.ToString(output.Update.Id)

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

func expandControlPlaneScalingConfig(tfList []any) *types.ControlPlaneScalingConfig {
if len(tfList) == 0 {
return nil
}

tfMap, ok := tfList[0].(map[string]any)
if !ok {
return nil
}

apiObject := &types.ControlPlaneScalingConfig{}

if v, ok := tfMap["tier"].(string); ok && v != "" {
apiObject.Tier = types.ProvisionedControlPlaneTier(v)
}

return apiObject
}

func expandEncryptionConfig(tfList []any) []types.EncryptionConfig {
if len(tfList) == 0 {
return nil
Expand Down Expand Up @@ -1585,6 +1646,18 @@ func flattenComputeConfigResponse(apiObject *types.ComputeConfigResponse) []map[
return []map[string]any{tfMap}
}

func flattenControlPlaneScalingConfig(apiObject *types.ControlPlaneScalingConfig) []any {
if apiObject == nil {
return nil
}

tfMap := map[string]any{
"tier": apiObject.Tier,
}

return []any{tfMap}
}

func flattenIdentity(apiObject *types.Identity) []map[string]any {
if apiObject == nil {
return []map[string]any{}
Expand Down
15 changes: 15 additions & 0 deletions internal/service/eks/cluster_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ func dataSourceCluster() *schema.Resource {
},
},
},
"control_plane_scaling_config": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"tier": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
names.AttrCreatedAt: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -350,6 +362,9 @@ func dataSourceClusterRead(ctx context.Context, d *schema.ResourceData, meta any
if err := d.Set("compute_config", flattenComputeConfigResponse(cluster.ComputeConfig)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting compute_config: %s", err)
}
if err := d.Set("control_plane_scaling_config", flattenControlPlaneScalingConfig(cluster.ControlPlaneScalingConfig)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting control_plane_scaling_config: %s", err)
}
d.Set(names.AttrCreatedAt, cluster.CreatedAt.Format(time.RFC3339))
d.Set(names.AttrDeletionProtection, cluster.DeletionProtection)
if err := d.Set("enabled_cluster_log_types", flattenLogging(cluster.Logging)); err != nil {
Expand Down
42 changes: 40 additions & 2 deletions internal/service/eks/cluster_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ func TestAccEKSClusterDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr(dataSourceResourceName, "certificate_authority.#", "1"),
resource.TestCheckResourceAttrPair(resourceName, "certificate_authority.0.data", dataSourceResourceName, "certificate_authority.0.data"),
resource.TestCheckNoResourceAttr(dataSourceResourceName, "cluster_id"),
resource.TestCheckResourceAttr(resourceName, "compute_config.#", "0"),
resource.TestCheckResourceAttr(resourceName, "compute_config.#", "1"),
resource.TestCheckResourceAttr(dataSourceResourceName, "control_plane_scaling_config.#", "1"),
resource.TestCheckResourceAttrPair(resourceName, "control_plane_scaling_config.0.tier", dataSourceResourceName, "control_plane_scaling_config.0.tier"),
resource.TestCheckResourceAttr(dataSourceResourceName, "control_plane_scaling_config.0.tier", "standard"),
resource.TestCheckResourceAttrPair(resourceName, names.AttrCreatedAt, dataSourceResourceName, names.AttrCreatedAt),
resource.TestCheckResourceAttrPair(resourceName, names.AttrDeletionProtection, dataSourceResourceName, names.AttrDeletionProtection),
resource.TestCheckResourceAttr(dataSourceResourceName, "enabled_cluster_log_types.#", "2"),
Expand All @@ -53,7 +56,7 @@ func TestAccEKSClusterDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr(dataSourceResourceName, "remote_network_config.#", "0"),
resource.TestCheckResourceAttrPair(resourceName, names.AttrRoleARN, dataSourceResourceName, names.AttrRoleARN),
resource.TestCheckResourceAttrPair(resourceName, names.AttrStatus, dataSourceResourceName, names.AttrStatus),
resource.TestCheckResourceAttr(resourceName, "storage_config.#", "0"),
resource.TestCheckResourceAttr(resourceName, "storage_config.#", "1"),
resource.TestCheckResourceAttrPair(resourceName, acctest.CtTagsPercent, dataSourceResourceName, acctest.CtTagsPercent),
resource.TestCheckResourceAttr(resourceName, "upgrade_policy.#", "1"),
resource.TestCheckResourceAttr(resourceName, "upgrade_policy.0.support_type", "EXTENDED"),
Expand Down Expand Up @@ -183,6 +186,33 @@ func TestAccEKSClusterDataSource_remoteNetwork(t *testing.T) {
})
}

func TestAccEKSClusterDataSource_controlPlaneScalingConfig(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
dataSourceResourceName := "data.aws_eks_cluster.test"
resourceName := "aws_eks_cluster.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.EKSServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckClusterDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccClusterDataSourceConfig_controlPlaneScalingConfig(rName, "tier-xl"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(resourceName, names.AttrARN, dataSourceResourceName, names.AttrARN),
resource.TestCheckResourceAttr(dataSourceResourceName, "control_plane_scaling_config.#", "1"),
resource.TestCheckResourceAttrPair(resourceName, "control_plane_scaling_config.0.tier", dataSourceResourceName, "control_plane_scaling_config.0.tier"),
resource.TestCheckResourceAttr(dataSourceResourceName, "control_plane_scaling_config.0.tier", "tier-xl"),
resource.TestCheckResourceAttrPair(resourceName, names.AttrName, dataSourceResourceName, names.AttrName),
resource.TestCheckResourceAttrPair(resourceName, names.AttrStatus, dataSourceResourceName, names.AttrStatus),
),
},
},
})
}

func testAccClusterDataSourceConfig_basic(rName string) string {
return acctest.ConfigCompose(testAccClusterConfig_logging(rName, []string{"api", "audit"}), `
data "aws_eks_cluster" "test" {
Expand All @@ -206,3 +236,11 @@ data "aws_eks_cluster" "test" {
}
`)
}

func testAccClusterDataSourceConfig_controlPlaneScalingConfig(rName, tier string) string {
return acctest.ConfigCompose(testAccClusterConfig_controlPlaneScalingConfig(rName, tier), `
data "aws_eks_cluster" "test" {
name = aws_eks_cluster.test.name
}
`)
}
60 changes: 60 additions & 0 deletions internal/service/eks/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func TestAccEKSCluster_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "certificate_authority.0.data"),
resource.TestCheckNoResourceAttr(resourceName, "cluster_id"),
resource.TestCheckResourceAttr(resourceName, "compute_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.0.tier", "standard"),
acctest.CheckResourceAttrRFC3339(resourceName, names.AttrCreatedAt),
resource.TestCheckResourceAttr(resourceName, names.AttrDeletionProtection, acctest.CtFalse),
resource.TestCheckResourceAttr(resourceName, "enabled_cluster_log_types.#", "0"),
Expand Down Expand Up @@ -626,6 +628,45 @@ func TestAccEKSCluster_ComputeConfig_AddARN(t *testing.T) {
})
}

func TestAccEKSCluster_controlPlaneScalingConfig(t *testing.T) {
ctx := acctest.Context(t)
var cluster1, cluster2 types.Cluster
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_eks_cluster.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.EKSServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckClusterDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccClusterConfig_controlPlaneScalingConfig(rName, "tier-xl"),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckClusterExists(ctx, resourceName, &cluster1),
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.0.tier", "tier-xl"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"bootstrap_self_managed_addons"},
},
{
Config: testAccClusterConfig_controlPlaneScalingConfig(rName, "standard"),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckClusterExists(ctx, resourceName, &cluster2),
testAccCheckClusterNotRecreated(&cluster1, &cluster2),
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "control_plane_scaling_config.0.tier", "standard"),
),
},
},
})
}

func TestAccEKSCluster_Encryption_create(t *testing.T) {
ctx := acctest.Context(t)
var cluster types.Cluster
Expand Down Expand Up @@ -2647,3 +2688,22 @@ resource "aws_eks_cluster" "test" {
}
`, rName, deletionProtection))
}

func testAccClusterConfig_controlPlaneScalingConfig(rName, tier string) string {
return acctest.ConfigCompose(testAccClusterConfig_base(rName), fmt.Sprintf(`
resource "aws_eks_cluster" "test" {
name = %[1]q
role_arn = aws_iam_role.cluster.arn

vpc_config {
subnet_ids = aws_subnet.test[*].id
}

control_plane_scaling_config {
tier = %[2]q
}

depends_on = [aws_iam_role_policy_attachment.cluster_AmazonEKSClusterPolicy]
}
`, rName, tier))
}
2 changes: 2 additions & 0 deletions website/docs/d/eks_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ This data source exports the following attributes in addition to the arguments a
* `enabled` - Whether the EKS Auto Mode compute capability is enabled or not.
* `node_pools` - List of node pools for the EKS Auto Mode compute capability.
* `node_role_arn` - The ARN of the IAM Role EKS will assign to EC2 Managed Instances in your EKS Auto Mode cluster.
* `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.
* `tier` - The control plane scaling tier. Valid values are `standard`, `tier-xl`, `tier-2xl`, or `tier-4xl`.
* `certificate_authority` - Nested attribute containing `certificate-authority-data` for your cluster.
* `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.
* `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.
Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/eks_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ The following arguments are optional:
* `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.
* `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`.
* `compute_config` - (Optional) Configuration block with compute configuration for EKS Auto Mode. [Detailed](#compute_config) below.
* `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.
* `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`.
* `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).
* `encryption_config` - (Optional) Configuration block with encryption configuration for the cluster. [Detailed](#encryption_config) below.
Expand Down Expand Up @@ -376,6 +377,12 @@ The `compute_config` configuration block supports the following arguments:
* `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`.
* `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..

### control_plane_scaling_config

The `control_plane_scaling_config` configuration block supports the following arguments:

* `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).

### encryption_config

The `encryption_config` configuration block supports the following arguments:
Expand Down
Loading