Skip to content

Commit

Permalink
update to follow change in aws_db_instance id
Browse files Browse the repository at this point in the history
aws_db_instance was updated by hashicorp/terraform-provider-aws#31232
such that the `id` attribute now tracks the resource ID, and the
identifier is now returned in a new attribute named `identifier`.

The resource ID is already available in `instance_resource_id`. This
fix allows existing users to continue using this module with no
changes and preserves the original function of the `id` attribute
in this module.

Fixes terraform-aws-modules#495.
  • Loading branch information
jwoytek committed Jun 20, 2023
1 parent 51ededc commit 3ca00c6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/db_instance/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ output "db_instance_hosted_zone_id" {

output "db_instance_id" {
description = "The RDS instance ID"
value = try(aws_db_instance.this[0].id, "")
value = try(aws_db_instance.this[0].identifier, "")
}

output "db_instance_resource_id" {
Expand Down

2 comments on commit 3ca00c6

@ricosega
Copy link

@ricosega ricosega commented on 3ca00c6 Jun 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwoytek there is no identifier in the outputs of the resource https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#attributes-reference
do you mean ?
value = try(local.identifier, "")

@jwoytek
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ricosega I was initially confused at the documentation as well and filed a documentation bug report on it, but one of the folks there let me know that it is indeed available, but listed under arguments because it can also be set by the caller (see: hashicorp/terraform-provider-aws#31854).

This has been tested using one of the module's provided examples and it works. local.identifier (even if it is available--I have not looked) would not work in any case, as when one does not set an identifier when creating a db_instance, AWS will generate one, so it must be retrieved from the db_instance resource.

Please sign in to comment.