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 instances try to be recreated when associated with a KMS Alias #229

Closed
hashibot opened this issue Jun 13, 2017 · 8 comments
Closed

RDS instances try to be recreated when associated with a KMS Alias #229

hashibot opened this issue Jun 13, 2017 · 8 comments
Labels
bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service.

Comments

@hashibot
Copy link

This issue was originally opened by @rcostanzo as hashicorp/terraform#8259. It was migrated here as part of the provider split. The original body of the issue is below.


You can properly create a RDS instance with the KMS Alias ARN as the kms_key_id, but subsequent runs then want to recreate that resource because the AWS returned value is the actual KMS Key's ARN, not the Alias's.

Terraform Version

0.7.0

Affected Resource(s)

  • aws_db_instance
  • aws_kms_alias

Terraform Configuration Files

resource "aws_kms_key" "rds" {
    ...
}

resource "aws_kms_alias" "rds" {
    name = "alias/key-rds-qa"
    target_key_id = "${aws_kms_key.rds.key_id}"
}

resource "aws_db_instance" "db-profile-2" {
    kms_key_id = "${aws_kms_alias.rds.arn}"
}

Expected Behavior

No changes should be detected

Actual Behavior

Terraform detects that the KMS Key changed and wants to recreate the RDS db resource:
kms_key_id: "arn:aws:kms:stuff:key/keyid" => "arn:aws:kms:stuff:alias/key-rds-qa" (forces new resource)

Steps to Reproduce

  1. Create a RDS instance with the kms_key_id equal to an alias
  2. Run a plan afterwards and see it wants to recreate it vs. being a no-op
@hashibot hashibot added the bug Addresses a defect in current functionality. label Jun 13, 2017
@ktel1218
Copy link

ktel1218 commented Jan 3, 2018

+1

@mogaal
Copy link

mogaal commented Jan 11, 2018

+1 facing the same issue. Does someone found a workaround?

@ktel1218
Copy link

ktel1218 commented Jan 11, 2018

I used the workaround here: #1477 (comment from @trung)

@radeksimko radeksimko added the service/rds Issues and PRs that pertain to the rds service. label Jan 25, 2018
@weskerfoot
Copy link

I also have this issue

@CyrilDevOps
Copy link

+1

1 similar comment
@pnduati
Copy link

pnduati commented Jun 10, 2020

+1

@bflad
Copy link
Contributor

bflad commented Oct 29, 2020

Hi everyone 👋 Since this issue was raised awhile ago, both the aws_kms_alias resource and data source now support a target_key_arn attribute, which is compatible with all kms_key_id arguments across all Terraform AWS Provider resources. This is the recommended path for all configurations experiencing this issue.

For some additional context, the maintainers do not intend to directly support KMS Alias ARNs due to how the AWS APIs always return the KMS Key ID. Since Terraform performs drift detection with configured values against the value stored in the Terraform state when refreshed by the resource, this difference would always show unless we introduced additional cross-service API calls to every resource that supports this parameter. This API call would occur every Terraform plan for every resource and could dramatically affect account-level KMS rate limiting along with permissions issues for restrictive environments. Given these operational concerns, we prefer to recommend the target_key_arn attribute.

If the documentation around this can be improved, please reach out.

@bflad bflad closed this as completed Oct 29, 2020
@ghost
Copy link

ghost commented Nov 29, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Nov 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
Development

No branches or pull requests

8 participants