Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_neptune_cluster: added allow_major_version_upgrade attribute #25140

Merged
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
2 changes: 2 additions & 0 deletions .changelog/25140.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
```release-note:enhancement
resource/aws_neptune_cluster: Add `allow_major_version_upgrade` argument.
13 changes: 11 additions & 2 deletions internal/service/neptune/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ func ResourceCluster() *schema.Resource {

Schema: map[string]*schema.Schema{

// allow_major_version_upgrade is used to indicate whether upgrades between different major versions
// are allowed.
"allow_major_version_upgrade": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},

// apply_immediately is used to determine when the update modifications
// take place.
"apply_immediately": {
Expand Down Expand Up @@ -560,8 +568,9 @@ func resourceClusterUpdate(d *schema.ResourceData, meta interface{}) error {
requestUpdate := false

req := &neptune.ModifyDBClusterInput{
ApplyImmediately: aws.Bool(d.Get("apply_immediately").(bool)),
DBClusterIdentifier: aws.String(d.Id()),
AllowMajorVersionUpgrade: aws.Bool(d.Get("allow_major_version_upgrade").(bool)),
ApplyImmediately: aws.Bool(d.Get("apply_immediately").(bool)),
DBClusterIdentifier: aws.String(d.Id()),
}

if d.HasChange("copy_tags_to_snapshot") {
Expand Down
105 changes: 95 additions & 10 deletions internal/service/neptune/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestAccNeptuneCluster_basic(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
},
Expand Down Expand Up @@ -88,6 +89,7 @@ func TestAccNeptuneCluster_copyTagsToSnapshot(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
{
Expand Down Expand Up @@ -135,6 +137,7 @@ func TestAccNeptuneCluster_namePrefix(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
},
Expand Down Expand Up @@ -167,6 +170,7 @@ func TestAccNeptuneCluster_takeFinalSnapshot(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
},
Expand Down Expand Up @@ -201,6 +205,7 @@ func TestAccNeptuneCluster_tags(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
{
Expand Down Expand Up @@ -264,6 +269,7 @@ func TestAccNeptuneCluster_updateIAMRoles(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
},
Expand Down Expand Up @@ -298,6 +304,7 @@ func TestAccNeptuneCluster_kmsKey(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
},
Expand Down Expand Up @@ -331,6 +338,7 @@ func TestAccNeptuneCluster_encrypted(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
},
Expand Down Expand Up @@ -375,6 +383,7 @@ func TestAccNeptuneCluster_backupsUpdate(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
},
Expand Down Expand Up @@ -408,6 +417,7 @@ func TestAccNeptuneCluster_iamAuth(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
},
Expand Down Expand Up @@ -456,6 +466,7 @@ func TestAccNeptuneCluster_updateCloudWatchLogsExports(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
},
Expand Down Expand Up @@ -489,6 +500,7 @@ func TestAccNeptuneCluster_updateEngineVersion(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
{
Expand All @@ -507,6 +519,60 @@ func TestAccNeptuneCluster_updateEngineVersion(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
},
})
}

func TestAccNeptuneCluster_updateEngineMajorVersion(t *testing.T) {
var dbCluster neptune.DBCluster
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_neptune_cluster.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ErrorCheck: acctest.ErrorCheck(t, neptune.EndpointsID),
ProviderFactories: acctest.ProviderFactories,
CheckDestroy: testAccCheckClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccClusterConfig_engineVersion(rName, "1.0.2.1"),
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterExists(resourceName, &dbCluster),
resource.TestCheckResourceAttr(resourceName, "engine_version", "1.0.2.1"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"apply_immediately",
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
{
Config: testAccClusterConfig_engineMajorVersionUpdate(rName, "1.1.1.0"),
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterExists(resourceName, &dbCluster),
resource.TestCheckResourceAttr(resourceName, "engine_version", "1.1.1.0"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"apply_immediately",
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
},
Expand Down Expand Up @@ -540,6 +606,7 @@ func TestAccNeptuneCluster_deleteProtection(t *testing.T) {
"cluster_identifier_prefix",
"final_snapshot_identifier",
"skip_final_snapshot",
"allow_major_version_upgrade",
},
},
{
Expand Down Expand Up @@ -1127,17 +1194,8 @@ resource "aws_neptune_cluster" "test" {
`, rName))
}

func testAccClusterConfig_engineVersion(rName, engineVersion string) string {
func testAccClusterConfig_engineVersionBase(rName string) string {
return acctest.ConfigCompose(testAccClusterBaseConfig(), fmt.Sprintf(`
resource "aws_neptune_cluster" "test" {
cluster_identifier = %[1]q
apply_immediately = true
availability_zones = local.availability_zone_names
engine_version = %[2]q
neptune_cluster_parameter_group_name = "default.neptune1"
skip_final_snapshot = true
}

data "aws_neptune_orderable_db_instance" "test" {
engine = "neptune"
engine_version = aws_neptune_cluster.test.engine_version
Expand All @@ -1154,5 +1212,32 @@ resource "aws_neptune_cluster_instance" "test" {
neptune_parameter_group_name = aws_neptune_cluster.test.neptune_cluster_parameter_group_name
promotion_tier = "3"
}
`, rName))
}

func testAccClusterConfig_engineVersion(rName, engineVersion string) string {
return acctest.ConfigCompose(testAccClusterConfig_engineVersionBase(rName), fmt.Sprintf(`
resource "aws_neptune_cluster" "test" {
cluster_identifier = %[1]q
apply_immediately = true
availability_zones = local.availability_zone_names
engine_version = %[2]q
neptune_cluster_parameter_group_name = "default.neptune1"
skip_final_snapshot = true
}
`, rName, engineVersion))
}

func testAccClusterConfig_engineMajorVersionUpdate(rName, engineVersion string) string {
return acctest.ConfigCompose(testAccClusterConfig_engineVersionBase(rName), fmt.Sprintf(`
resource "aws_neptune_cluster" "test" {
cluster_identifier = %[1]q
apply_immediately = true
availability_zones = local.availability_zone_names
engine_version = %[2]q
neptune_cluster_parameter_group_name = "default.neptune1"
skip_final_snapshot = true
allow_major_version_upgrade = true
}
`, rName, engineVersion))
}
1 change: 1 addition & 0 deletions website/docs/r/neptune_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ See the AWS [Docs](https://docs.aws.amazon.com/neptune/latest/userguide/limits.h

The following arguments are supported:

* `allow_major_version_upgrade` - (Optional) Specifies whether upgrades between different major versions are allowed. You must set it to `true` when providing an `engine_version` parameter that uses a different major version than the DB cluster's current version. Default is `false`.
* `apply_immediately` - (Optional) Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is `false`.
* `availability_zones` - (Optional) A list of EC2 Availability Zones that instances in the Neptune cluster can be created in.
* `backup_retention_period` - (Optional) The days to retain backups for. Default `1`
Expand Down