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

rds: Improve version/instance data sources #35698

Merged
merged 23 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a0bc51b
rds/cluster: Improve tests
YakDriver Feb 7, 2024
c93e7aa
rds/consts: Fix mispelling
YakDriver Feb 7, 2024
65fa729
Add changelog
YakDriver Feb 7, 2024
68c626f
rds/cluster: Revise tests to improve data source use
YakDriver Feb 7, 2024
8cfa741
rds/consts: Add main preferred instance classes
YakDriver Feb 7, 2024
4836a41
rds/engine_version: Update search options and functionality
YakDriver Feb 7, 2024
5b211d3
rds/engine_version: Update tests for new functionality
YakDriver Feb 7, 2024
2dc9a5b
rds/orderable_instance: Add new functionality
YakDriver Feb 7, 2024
6045f1f
rds/orderable_instance: Update tests for new functionality
YakDriver Feb 7, 2024
63bdc08
docs/rds: Update engine_version docs for changes
YakDriver Feb 7, 2024
1f3fca6
docs/rds: Update orderable_instance docs for changes
YakDriver Feb 7, 2024
1776cf5
Update go.mod
YakDriver Feb 7, 2024
2bf3115
rds/neptune: Small corrections
YakDriver Feb 8, 2024
794a7a6
rds: Post-rebase cleanup
YakDriver Feb 8, 2024
f8d8463
rds/cluster: Fix tests
YakDriver Feb 8, 2024
433a7f9
aws/rds: Tweak tests
YakDriver Feb 8, 2024
588bbb2
rds: Clean up some lint
YakDriver Feb 8, 2024
53920bd
rds/instance: Fix test linting
YakDriver Feb 8, 2024
76c90e4
rds: Fix minor issues
YakDriver Feb 8, 2024
2ca0e35
rds/instance: Remove extra comment
YakDriver Feb 8, 2024
3c49d41
rds/consts: Remove unused
YakDriver Feb 8, 2024
c0a95af
rds: Make code more readable
YakDriver Feb 9, 2024
6154e5f
rds/orderable_instance: Improve performance
YakDriver Feb 9, 2024
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
15 changes: 15 additions & 0 deletions .changelog/35698.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```release-note:enhancement
data-source/aws_rds_orderable_db_instance: Improve search functionality and options by adding `engine_latest_version` and `supports_clusters` arguments and converting `read_replica_capable`, `supported_engine_modes`, `supported_network_types`, and `supports_multi_az` to arguments for use as search criteria
```

```release-note:enhancement
data-source/aws_rds_engine_version: Improve search functionality and options by adding `latest`, `preferred_major_targets`, and `preferred_upgrade_targets`. Add `version_actual` attribute
```

```release-note:new-data-source
aws_db_parameter_group
```

```release-note:enhancement
data-source/aws_neptune_cluster_instance: Add `skip_final_snapshot` argument
```
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.20

require (
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c
github.com/YakDriver/go-version v0.1.0
github.com/YakDriver/regexache v0.23.0
github.com/aws/aws-sdk-go v1.50.12
github.com/aws/aws-sdk-go-v2 v1.24.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBa
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX7IL/m9Y5LO+KQYv+t1CQOiFe6+SV2J7bE=
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/YakDriver/go-version v0.1.0 h1:/x+Xg2+l89Mjtxl0VRf2+ue8cnHkw6jfYv49j6f7gZw=
github.com/YakDriver/go-version v0.1.0/go.mod h1:LXwFAp1E3KBhS7FHO/FE8r3XCmvKizs/VXXXFWfoSYY=
github.com/YakDriver/regexache v0.23.0 h1:kv3j4XKhbx/vqUilSBgizXDUXHvvH1KdYekdmGwz4C4=
github.com/YakDriver/regexache v0.23.0/go.mod h1:K4BZ3MYKAqSFbYWqmbsG+OzYUDyJjnMEr27DJEsVG3U=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
Expand Down
14 changes: 12 additions & 2 deletions internal/service/neptune/cluster_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ func ResourceClusterInstance() *schema.Resource {
Default: false,
ForceNew: true,
},
"skip_final_snapshot": {
Type: schema.TypeBool,
Optional: true,
},
"storage_encrypted": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -363,9 +367,15 @@ func resourceClusterInstanceDelete(ctx context.Context, d *schema.ResourceData,
conn := meta.(*conns.AWSClient).NeptuneConn(ctx)

log.Printf("[DEBUG] Deleting Neptune Cluster Instance: %s", d.Id())
_, err := conn.DeleteDBInstanceWithContext(ctx, &neptune.DeleteDBInstanceInput{
input := neptune.DeleteDBInstanceInput{
DBInstanceIdentifier: aws.String(d.Id()),
})
}

if d.Get("skip_final_snapshot").(bool) {
input.SkipFinalSnapshot = aws.Bool(true)
}

_, err := conn.DeleteDBInstanceWithContext(ctx, &input)

if tfawserr.ErrCodeEquals(err, neptune.ErrCodeDBInstanceNotFoundFault) {
return diags
Expand Down
1 change: 1 addition & 0 deletions internal/service/neptune/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ func sweepClusterInstances(region string) error {
d := r.Data(nil)
d.SetId(id)
d.Set("apply_immediately", true)
d.Set("skip_final_snapshot", true)

sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client))
}
Expand Down
1,010 changes: 565 additions & 445 deletions internal/service/rds/cluster_test.go

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion internal/service/rds/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func StorageType_Values() []string {
}

const (
InstanceEngineAuroraMySQL = "aurora-mysql"
InstanceEngineAuroraPostgreSQL = "aurora-postgresql"
InstanceEngineCustomPrefix = "custom-"
InstanceEngineDB2Advanced = "db2-ae"
InstanceEngineDB2Standard = "db2-se"
Expand All @@ -67,7 +69,7 @@ const (
InstanceEngineSQLServerEnterprise = "sqlserver-ee"
InstanceEngineSQLServerExpress = "sqlserver-ex"
InstanceEngineSQLServerStandard = "sqlserver-se"
InstanceEngineSQLServerWeb = "sqlserver-ewb"
InstanceEngineSQLServerWeb = "sqlserver-web"
)

// https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/accessing-monitoring.html#Overview.DBInstance.Status.
Expand Down
75 changes: 63 additions & 12 deletions internal/service/rds/consts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,67 @@

package rds_test

const (
// Please make sure GovCloud and commercial support these since they vary
db2PreferredInstanceClasses = `"db.t3.small", "db.r6i.large", "db.m6i.large"`
mariaDBPreferredInstanceClasses = `"db.t3.micro", "db.t3.small", "db.t2.small", "db.t2.medium"`
mySQLPreferredInstanceClasses = `"db.t3.micro", "db.t3.small", "db.t2.small", "db.t2.medium"`
oraclePreferredInstanceClasses = `"db.t3.medium", "db.t2.medium", "db.t3.large", "db.t2.large"` // Oracle requires at least a medium instance as a replica source
oracleSE2PreferredInstanceClasses = `"db.m5.large", "db.m4.large", "db.r4.large"`
outpostPreferredInstanceClasses = `"db.m5.large", "db.r5.large"` // https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-on-outposts.db-instance-classes.html
postgresPreferredInstanceClasses = `"db.t3.micro", "db.t3.small", "db.t2.small", "db.t2.medium"`
sqlServerCustomPreferredInstanceClasses = `"db.m5.large", "db.m5.xlarge"`
sqlServerPreferredInstanceClasses = `"db.t2.small", "db.t3.small"`
sqlServerSEPreferredInstanceClasses = `"db.m5.large", "db.m4.large", "db.r4.large"`
import "strings"

var (
// Prices for mysql as of 2024-02-02 in us-west-2 which are representative of
// relative prices in other regions. Prices are per hour.
instanceClassesSlice = []string{
/* 0.016 */ `"db.t4g.micro"`,
/* 0.017 */ `"db.t3.micro"`,
/* 0.032 */ `"db.t4g.small"`,
/* 0.034 */ `"db.t3.small"`,
/* 0.065 */ `"db.t4g.medium"`,
/* 0.068 */ `"db.t3.medium"`,
/* 0.129 */ `"db.t4g.large"`,
/* 0.136 */ `"db.t3.large"`,
/* 0.152 */ `"db.m6g.large"`,
/* 0.168 */ `"db.m7g.large"`,
/* 0.171 */ `"db.m5.large"`,
/* 0.171 */ `"db.m6i.large"`,
/* 0.187 */ `"db.m6gd.large"`,
/* 0.210 */ `"db.m5d.large"`,
/* 0.215 */ `"db.r6g.large"`,
/* 0.224 */ `"db.m6id.large"`,
/* 0.239 */ `"db.r7g.large"`,
/* 0.240 */ `"db.r5.large"`,
/* 0.240 */ `"db.r6i.large"`,
/* 0.257 */ `"db.r6gd.large"`,
/* 0.258 */ `"db.m6in.large"`,
/* 0.258 */ `"db.t4g.xlarge"`,
/* 0.272 */ `"db.t3.xlarge"`,
/* 0.286 */ `"db.r5d.large"`,
/* 0.295 */ `"db.m6idn.large"`,
/* 0.296 */ `"db.r5b.large"`,
/* 0.298 */ `"db.r6id.large"`,
/* 0.304 */ `"db.m6g.xlarge"`,
/* 0.326 */ `"db.x2g.large"`,
/* 0.337 */ `"db.m7g.xlarge"`,
/* 0.342 */ `"db.m5.xlarge"`,
/* 0.342 */ `"db.m6i.xlarge"`,
/* 0.346 */ `"db.r6in.large"`,
/* 0.373 */ `"db.m6gd.xlarge"`,
/* 0.388 */ `"db.r6idn.large"`,
/* 0.419 */ `"db.m5d.xlarge"`,
/* 0.430 */ `"db.r6g.xlarge"`,
/* 0.448 */ `"db.m6id.xlarge"`,
/* 0.478 */ `"db.r7g.xlarge"`,
/* 0.480 */ `"db.r5.xlarge"`,
/* 0.480 */ `"db.r6i.xlarge"`,
/* 0.514 */ `"db.r6gd.xlarge"`,
/* 0.516 */ `"db.m6in.xlarge"`,
/* 0.517 */ `"db.t4g.2xlarge"`,
/* 0.544 */ `"db.t3.2xlarge"`,
/* 0.571 */ `"db.r5d.xlarge"`,
/* 0.590 */ `"db.m6idn.xlarge"`,
/* 0.592 */ `"db.r5b.xlarge"`,
/* 0.596 */ `"db.r6id.xlarge"`,
}

// These instance classes will be selected in order. Use sufficient criteria
// with aws_rds_engine_version and aws_rds_orderable_db_instance to ensure
// one is selected with the features you need.
// Prices for mysql as of 2024-02-02 in us-west-2 which are representative of
// relative prices in other regions. Prices are per hour.
mainInstanceClasses = strings.Join(instanceClassesSlice, ", ")
)
Loading
Loading