Skip to content

Commit

Permalink
Merge pull request #38295 from sasidhar-aws/b-bootstrap_cluster_creat…
Browse files Browse the repository at this point in the history
…or_admin_permissions

bootstrap_cluster_creator_admin_permissions value fix when access_config is not provided at eks cluster creation
  • Loading branch information
ewbankkit authored Jul 10, 2024
2 parents 84ebeab + f37ccce commit a73ade2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changelog/38295.txt
Original file line number Diff line number Diff line change
@@ -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
```
4 changes: 4 additions & 0 deletions internal/service/eks/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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}
Expand Down
4 changes: 4 additions & 0 deletions internal/service/eks/cluster_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func dataSourceCluster() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"bootstrap_cluster_creator_admin_permissions": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},
Expand Down
12 changes: 12 additions & 0 deletions internal/service/eks/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/eks_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a73ade2

Please sign in to comment.