diff --git a/.changelog/38295.txt b/.changelog/38295.txt new file mode 100644 index 000000000000..56508de28faa --- /dev/null +++ b/.changelog/38295.txt @@ -0,0 +1,7 @@ +```release-note:bug +resource/aws_eks_cluster: Set `access_config.bootstrap_cluster_creator_admin_permissions` to `true` on Read for clusters with no `access_config` configured. This allows in-place updates of existing clusters when `access_config` is configured +``` + +```release-note:bug +data-source/aws_eks_cluster: Add `access_config.bootstrap_cluster_creator_admin_permissions` attribute +``` \ No newline at end of file diff --git a/internal/service/eks/cluster.go b/internal/service/eks/cluster.go index 343c607a73c9..bb28f67a71c6 100644 --- a/internal/service/eks/cluster.go +++ b/internal/service/eks/cluster.go @@ -424,6 +424,7 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter } // bootstrap_cluster_creator_admin_permissions isn't returned from the AWS API. + // See https://github.com/aws/containers-roadmap/issues/185#issuecomment-1863025784. var bootstrapClusterCreatorAdminPermissions *bool if v, ok := d.GetOk("access_config"); ok { if apiObject := expandCreateAccessConfigRequest(v.([]interface{})); apiObject != nil { @@ -1068,6 +1069,9 @@ func flattenAccessConfigResponse(apiObject *types.AccessConfigResponse, bootstra if bootstrapClusterCreatorAdminPermissions != nil { tfMap["bootstrap_cluster_creator_admin_permissions"] = aws.ToBool(bootstrapClusterCreatorAdminPermissions) + } else { + // Setting default value to true for backward compatibility. + tfMap["bootstrap_cluster_creator_admin_permissions"] = true } return []interface{}{tfMap} diff --git a/internal/service/eks/cluster_data_source.go b/internal/service/eks/cluster_data_source.go index 072b6663aaca..092bf3b810bc 100644 --- a/internal/service/eks/cluster_data_source.go +++ b/internal/service/eks/cluster_data_source.go @@ -30,6 +30,10 @@ func dataSourceCluster() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "bootstrap_cluster_creator_admin_permissions": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, diff --git a/internal/service/eks/cluster_test.go b/internal/service/eks/cluster_test.go index bc38c08af8dd..0f3162b9abbe 100644 --- a/internal/service/eks/cluster_test.go +++ b/internal/service/eks/cluster_test.go @@ -159,10 +159,17 @@ func TestAccEKSCluster_AccessConfig_update(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckClusterExists(ctx, resourceName, &cluster), resource.TestCheckResourceAttr(resourceName, "access_config.#", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "access_config.0.authentication_mode", string(types.AuthenticationModeConfigMap)), + resource.TestCheckResourceAttr(resourceName, "access_config.0.bootstrap_cluster_creator_admin_permissions", acctest.CtTrue), ), }, { Config: testAccClusterConfig_accessConfig(rName, types.AuthenticationModeConfigMap), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, Check: resource.ComposeTestCheckFunc( testAccCheckClusterExists(ctx, resourceName, &cluster), resource.TestCheckResourceAttr(resourceName, "access_config.#", acctest.Ct1), @@ -172,6 +179,11 @@ func TestAccEKSCluster_AccessConfig_update(t *testing.T) { }, { Config: testAccClusterConfig_accessConfig(rName, types.AuthenticationModeApiAndConfigMap), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate), + }, + }, Check: resource.ComposeTestCheckFunc( testAccCheckClusterExists(ctx, resourceName, &cluster), resource.TestCheckResourceAttr(resourceName, "access_config.#", acctest.Ct1), diff --git a/website/docs/r/eks_cluster.html.markdown b/website/docs/r/eks_cluster.html.markdown index 6031384062bd..7a298d616ad3 100644 --- a/website/docs/r/eks_cluster.html.markdown +++ b/website/docs/r/eks_cluster.html.markdown @@ -228,7 +228,7 @@ The following arguments are optional: The `access_config` configuration block supports the following arguments: * `authentication_mode` - (Optional) The authentication mode for the cluster. Valid values are `CONFIG_MAP`, `API` or `API_AND_CONFIG_MAP` -* `bootstrap_cluster_creator_admin_permissions` - (Optional) Whether or not to bootstrap the access config values to the cluster. Default is `true`. +* `bootstrap_cluster_creator_admin_permissions` - (Optional) Whether or not to bootstrap the access config values to the cluster. Default is `false`. ### encryption_config