Skip to content

Commit 2e9279e

Browse files
authored
Merge pull request #31232 from hashicorp/f-db-instance-identifier-not-forcenew
rds/instance: NEW ID configuration
2 parents dad8cc7 + e7e04e8 commit 2e9279e

28 files changed

+997
-290
lines changed

.changelog/31232.txt

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
```release-note:breaking-change
2+
resource/aws_db_instance: Remove `name` - use `db_name` instead
3+
```
4+
5+
```release-note:enhancement
6+
resource/aws_db_instance: Updates to `identifier` and `identifier_prefix` will no longer cause the database instance to be destroyed and recreated
7+
```
8+
9+
```release-note:breaking-change
10+
resource/aws_db_instance: `id` is no longer the AWS database `identifier` - `id` is now the `dbi-resource-id`. Refer to `identifier` instead of `id` to use the database's identifier
11+
```
12+
13+
```release-note:note
14+
resource/aws_db_instance: The change of what `id` is, namely, a DBI Resource ID now versus DB Identifier previously, has far-reaching consequences. Configurations that refer to, for example, `aws_db_instance.example.id` will now have errors and must be changed to use `identifier` instead, for example, `aws_db_instance.example.identifier`
15+
```
16+
17+
```release-note:note
18+
resource/aws_db_snapshot: Configurations that define `db_instance_identifier` using the `id` attribute of `aws_db_instance` must be updated to use `identifier` instead - for example, `db_instance_identifier = aws_db_instance.example.id` must be updated to `db_instance_identifier = aws_db_instance.example.identifier`
19+
```
20+
21+
```release-note:note
22+
resource/aws_db_instance: Configurations that define `replicate_source_db` using the `id` attribute of `aws_db_instance` must be updated to use `identifier` instead - for example, `replicate_source_db = aws_db_instance.example.id` must be updated to `replicate_source_db = aws_db_instance.example.identifier`
23+
```
24+
25+
```release-note:note
26+
resource/aws_db_instance_role_association: Configurations that define `db_instance_identifier` using the `id` attribute of `aws_db_instance` must be updated to use `identifier` instead - for example, `db_instance_identifier = aws_db_instance.example.id` must be updated to `db_instance_identifier = aws_db_instance.example.identifier`
27+
```
28+
29+
```release-note:note
30+
resource/aws_db_proxy_target: Configurations that define `db_instance_identifier` using the `id` attribute of `aws_db_instance` must be updated to use `identifier` instead - for example, `db_instance_identifier = aws_db_instance.example.id` must be updated to `db_instance_identifier = aws_db_instance.example.identifier`
31+
```
32+
33+
```release-note:note
34+
resource/aws_db_event_subscription: Configurations that define `source_ids` using the `id` attribute of `aws_db_instance` must be updated to use `identifier` instead - for example, `source_ids = [aws_db_instance.example.id]` must be updated to `source_ids = [aws_db_instance.example.identifier]`
35+
```

examples/rds/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ resource "aws_db_instance" "default" {
1313
engine = var.engine
1414
engine_version = var.engine_version[var.engine]
1515
instance_class = var.instance_class
16-
name = var.db_name
16+
db_name = var.db_name
1717
username = var.username
1818
password = var.password
1919
vpc_security_group_ids = [aws_security_group.default.id]

examples/rds/outputs.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ output "subnet_group" {
33
}
44

55
output "db_instance_id" {
6-
value = aws_db_instance.default.id
6+
value = aws_db_instance.default.identifier
77
}
88

99
output "db_instance_address" {

internal/service/rds/blue_green.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (h *instanceHandler) precondition(ctx context.Context, d *schema.ResourceDa
9797
needsPreConditions := false
9898
input := &rds_sdkv2.ModifyDBInstanceInput{
9999
ApplyImmediately: true,
100-
DBInstanceIdentifier: aws.String(d.Id()),
100+
DBInstanceIdentifier: aws.String(d.Get("identifier").(string)),
101101
}
102102

103103
// Backups must be enabled for Blue/Green Deployments. Enable them first.
@@ -113,7 +113,7 @@ func (h *instanceHandler) precondition(ctx context.Context, d *schema.ResourceDa
113113
}
114114

115115
if needsPreConditions {
116-
err := dbInstanceModify(ctx, h.conn, input, d.Timeout(schema.TimeoutUpdate))
116+
err := dbInstanceModify(ctx, h.conn, d.Id(), input, d.Timeout(schema.TimeoutUpdate))
117117
if err != nil {
118118
return fmt.Errorf("setting pre-conditions: %s", err)
119119
}
@@ -123,7 +123,7 @@ func (h *instanceHandler) precondition(ctx context.Context, d *schema.ResourceDa
123123

124124
func (h *instanceHandler) createBlueGreenInput(d *schema.ResourceData) *rds_sdkv2.CreateBlueGreenDeploymentInput {
125125
input := &rds_sdkv2.CreateBlueGreenDeploymentInput{
126-
BlueGreenDeploymentName: aws.String(d.Id()),
126+
BlueGreenDeploymentName: aws.String(d.Get("identifier").(string)),
127127
Source: aws.String(d.Get("arn").(string)),
128128
}
129129

@@ -148,7 +148,7 @@ func (h *instanceHandler) modifyTarget(ctx context.Context, identifier string, d
148148
if needsModify {
149149
log.Printf("[DEBUG] %s: Updating Green environment", operation)
150150

151-
err := dbInstanceModify(ctx, h.conn, modifyInput, timeout)
151+
err := dbInstanceModify(ctx, h.conn, d.Id(), modifyInput, timeout)
152152
if err != nil {
153153
return fmt.Errorf("updating Green environment: %s", err)
154154
}

internal/service/rds/export_task_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ resource "aws_db_instance" "test" {
253253
}
254254
255255
resource "aws_db_snapshot" "test" {
256-
db_instance_identifier = aws_db_instance.test.id
256+
db_instance_identifier = aws_db_instance.test.identifier
257257
db_snapshot_identifier = %[1]q
258258
}
259259
`, rName)

0 commit comments

Comments
 (0)