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/instance: NEW ID configuration #31232

Merged
merged 19 commits into from
May 13, 2023
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
35 changes: 35 additions & 0 deletions .changelog/31232.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
```release-note:breaking-change
resource/aws_db_instance: Remove `name` - use `db_name` instead
```

```release-note:enhancement
resource/aws_db_instance: Updates to `identifier` and `identifier_prefix` will no longer cause the database instance to be destroyed and recreated
```

```release-note:breaking-change
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
```

```release-note:note
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`
```

```release-note:note
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`
```

```release-note:note
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`
```

```release-note:note
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`
```

```release-note:note
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`
```

```release-note:note
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]`
```
2 changes: 1 addition & 1 deletion examples/rds/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource "aws_db_instance" "default" {
engine = var.engine
engine_version = var.engine_version[var.engine]
instance_class = var.instance_class
name = var.db_name
db_name = var.db_name
username = var.username
password = var.password
vpc_security_group_ids = [aws_security_group.default.id]
Expand Down
2 changes: 1 addition & 1 deletion examples/rds/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ output "subnet_group" {
}

output "db_instance_id" {
value = aws_db_instance.default.id
value = aws_db_instance.default.identifier
}

output "db_instance_address" {
Expand Down
8 changes: 4 additions & 4 deletions internal/service/rds/blue_green.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (h *instanceHandler) precondition(ctx context.Context, d *schema.ResourceDa
needsPreConditions := false
input := &rds_sdkv2.ModifyDBInstanceInput{
ApplyImmediately: true,
DBInstanceIdentifier: aws.String(d.Id()),
DBInstanceIdentifier: aws.String(d.Get("identifier").(string)),
}

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

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

func (h *instanceHandler) createBlueGreenInput(d *schema.ResourceData) *rds_sdkv2.CreateBlueGreenDeploymentInput {
input := &rds_sdkv2.CreateBlueGreenDeploymentInput{
BlueGreenDeploymentName: aws.String(d.Id()),
BlueGreenDeploymentName: aws.String(d.Get("identifier").(string)),
Source: aws.String(d.Get("arn").(string)),
}

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

err := dbInstanceModify(ctx, h.conn, modifyInput, timeout)
err := dbInstanceModify(ctx, h.conn, d.Id(), modifyInput, timeout)
if err != nil {
return fmt.Errorf("updating Green environment: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/service/rds/export_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ resource "aws_db_instance" "test" {
}

resource "aws_db_snapshot" "test" {
db_instance_identifier = aws_db_instance.test.id
db_instance_identifier = aws_db_instance.test.identifier
db_snapshot_identifier = %[1]q
}
`, rName)
Expand Down
Loading