diff --git a/aws/resource_aws_eks_node_group.go b/aws/resource_aws_eks_node_group.go index a646912cdaa..4c9a485a36b 100644 --- a/aws/resource_aws_eks_node_group.go +++ b/aws/resource_aws_eks_node_group.go @@ -378,7 +378,7 @@ func resourceAwsEksNodeGroupUpdate(d *schema.ResourceData, meta interface{}) err NodegroupName: aws.String(nodeGroupName), } - if v, ok := d.GetOk("release_version"); ok { + if v, ok := d.GetOk("release_version"); ok && d.HasChange("release_version") { input.ReleaseVersion = aws.String(v.(string)) } diff --git a/aws/resource_aws_eks_node_group_test.go b/aws/resource_aws_eks_node_group_test.go index 42a1cc87816..90f44843ab0 100644 --- a/aws/resource_aws_eks_node_group_test.go +++ b/aws/resource_aws_eks_node_group_test.go @@ -280,7 +280,7 @@ func TestAccAWSEksNodeGroup_ReleaseVersion(t *testing.T) { CheckDestroy: testAccCheckAWSEksNodeGroupDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEksNodeGroupConfigReleaseVersion(rName), + Config: testAccAWSEksNodeGroupConfigReleaseVersion(rName, "1.15"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEksNodeGroupExists(resourceName, &nodeGroup1), resource.TestCheckResourceAttrPair(resourceName, "release_version", ssmParameterDataSourceName, "value"), @@ -291,6 +291,13 @@ func TestAccAWSEksNodeGroup_ReleaseVersion(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + Config: testAccAWSEksNodeGroupConfigReleaseVersion(rName, "1.16"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEksNodeGroupExists(resourceName, &nodeGroup1), + resource.TestCheckResourceAttrPair(resourceName, "release_version", ssmParameterDataSourceName, "value"), + ), + }, }, }) } @@ -521,10 +528,10 @@ func TestAccAWSEksNodeGroup_Version(t *testing.T) { CheckDestroy: testAccCheckAWSEksNodeGroupDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEksNodeGroupConfigVersion(rName, "1.14"), + Config: testAccAWSEksNodeGroupConfigVersion(rName, "1.15"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEksNodeGroupExists(resourceName, &nodeGroup1), - resource.TestCheckResourceAttr(resourceName, "version", "1.14"), + resource.TestCheckResourceAttr(resourceName, "version", "1.15"), ), }, { @@ -532,6 +539,13 @@ func TestAccAWSEksNodeGroup_Version(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + Config: testAccAWSEksNodeGroupConfigVersion(rName, "1.16"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEksNodeGroupExists(resourceName, &nodeGroup1), + resource.TestCheckResourceAttr(resourceName, "version", "1.16"), + ), + }, }, }) } @@ -966,8 +980,8 @@ resource "aws_eks_node_group" "test" { `, rName, labelKey1, labelValue1, labelKey2, labelValue2) } -func testAccAWSEksNodeGroupConfigReleaseVersion(rName string) string { - return testAccAWSEksNodeGroupConfigBase(rName) + fmt.Sprintf(` +func testAccAWSEksNodeGroupConfigReleaseVersion(rName string, version string) string { + return testAccAWSEksNodeGroupConfigBaseVersion(rName, version) + fmt.Sprintf(` data "aws_ssm_parameter" "test" { name = "/aws/service/eks/optimized-ami/${aws_eks_cluster.test.version}/amazon-linux-2/recommended/release_version" } @@ -978,6 +992,7 @@ resource "aws_eks_node_group" "test" { node_role_arn = aws_iam_role.node.arn release_version = data.aws_ssm_parameter.test.value subnet_ids = aws_subnet.test[*].id + version = aws_eks_cluster.test.version scaling_config { desired_size = 1