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

dynamodb: Can't update PITR on inline table replicas when CMK #26552

Closed
szesch opened this issue Aug 30, 2022 · 3 comments · Fixed by #29102
Closed

dynamodb: Can't update PITR on inline table replicas when CMK #26552

szesch opened this issue Aug 30, 2022 · 3 comments · Fixed by #29102
Labels
bug Addresses a defect in current functionality. service/dynamodb Issues and PRs that pertain to the dynamodb service. service/kms Issues and PRs that pertain to the kms service.
Milestone

Comments

@szesch
Copy link
Contributor

szesch commented Aug 30, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v1.2.8
registry.terraform.io/hashicorp/aws v4.28.0

Affected Resource(s)

  • aws_dynamodb_table

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

provider "aws" {
  region  = "us-east-2"
}

provider "aws" {
  region  = "us-west-2"
  alias   = "uswest2"
}

provider "aws" {
  region  = "eu-west-2"
  alias   = "euwest2"
}

resource "aws_kms_key" "us_east_2" {
  description = "CMK for us-east-2"
}

resource "aws_kms_key" "us_west_2" {
  description = "CMK for us-west-2"
  provider    = aws.uswest2
}

resource "aws_kms_key" "eu_west_2" {
  description = "CMK for eu-west-2"
  provider    = aws.euwest2
}

resource "aws_dynamodb_table" "test" {
  name           = "replica-pitr-test"
  billing_mode   = "PAY_PER_REQUEST"
  hash_key       = "id"
  stream_enabled = true

  point_in_time_recovery {
    enabled = true
  }

  server_side_encryption {
    enabled     = true
    kms_key_arn = aws_kms_key.us_east_2.arn
  }

  attribute {
    name = "id"
    type = "S"
  }

  replica {
    region_name = "us-west-2"
    kms_key_arn = aws_kms_key.us_west_2.arn
    #point_in_time_recovery = true
  }

  replica {
    region_name = "eu-west-2"
    kms_key_arn = aws_kms_key.eu_west_2.arn
    #point_in_time_recovery = true
  }
}

Debug Output

https://gist.github.com/szesch/69e6025e6670be53c85c96142f6f9283

Expected Behavior

When enabling PITR for global table replicas, each replica should have its PITR updated accordingly.

Actual Behavior

The following error occurs and PITR recovery is not updated for the replicas

aws_dynamodb_table.test: Modifying... [id=replica-pitr-test]
╷
│ Error: updating Amazon DynamoDB Table (replica-pitr-test): updating replicas, while creating: creating replica (us-west-2): ValidationException: One or more parameter values were invalid: KMSMasterKeyId must be specified for each replica.
│       status code: 400, request id: GG3TINE9O3KKHJ5TVNBPDBQK37VV4KQNSO5AEMVJF66Q9ASUAAJG
│ 
│   with aws_dynamodb_table.test,
│   on main.tf line 32, in resource "aws_dynamodb_table" "test":
│   32: resource "aws_dynamodb_table" "test" {

This happens because the UpdateTable API call is made with only a single replica instead of all replicas.

. This causes the error to be returned from the API. This can be reproduced with the AWS CLI. If a call is made with a single replica it will fail with the same error but if a call is made with all replicas it will succeed. Since this UpdateTable call fails before the call to update PITR on replicas, that code path is never executed.

Steps to Reproduce

  1. terraform apply to create the global dynamodb table
  2. Edit the configuration to uncomment PITR for the replicas
  3. plan and apply
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/dynamodb Issues and PRs that pertain to the dynamodb service. service/kms Issues and PRs that pertain to the kms service. labels Aug 30, 2022
@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Aug 30, 2022
@YakDriver
Copy link
Member

Related #28814
Related #24903
Related #27850

As mentioned in #28814 (comment), without KMS keys, PITR enable updates are working fine. The problem appears to be isolated to KMS.

@YakDriver YakDriver changed the title Can't update PITR on dynamodb replicas dynamodb: Can't update PITR on inline table replicas when CMK Jan 26, 2023
@github-actions github-actions bot added this to the v4.52.0 milestone Jan 27, 2023
@github-actions
Copy link

This functionality has been released in v4.52.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 27, 2023
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/dynamodb Issues and PRs that pertain to the dynamodb service. service/kms Issues and PRs that pertain to the kms service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants