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

Add validate DynamoDB indexes #6364

Closed
wants to merge 1 commit into from
Closed

Add validate DynamoDB indexes #6364

wants to merge 1 commit into from

Conversation

178inaba
Copy link
Contributor

@178inaba 178inaba commented Nov 5, 2018

Nice to meet you.

Changes proposed in this pull request:

  • In the DynamoDB validation, when there is an index which does not exist in the attribute, I fixed to be an error.

There was no original test in validateDynamoDbTableAttributes.
I thought about writing a test but stopped because I did not know how to create the argument schema.ResourceDiff.

I performed this fix on terraform plan and confirmed that the results are correct.
The following is the execution log at that time.

main.tf

terraform {
  required_version = "> 0.11.0"
}

provider "aws" {
  region = "ap-northeast-1"
}

resource "aws_dynamodb_table" "test_table" {
  name           = "TestTable"
  hash_key       = "ID"
  range_key      = "UserID"
  read_capacity  = 5
  write_capacity = 5

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

  local_secondary_index {
    name            = "StatusIndex"
    range_key       = "Status"
    projection_type = "KEY_ONLY"
  }
}

log

$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.


------------------------------------------------------------------------

Error: Error running plan: 1 error(s) occurred:

* aws_dynamodb_table.test_table: 1 error(s) occurred:

* aws_dynamodb_table.test_table: All indexes must be attribute. Unused indexes: ["UserID" "Status"]

@ghost ghost added the size/XS Managed by automation to categorize the size of a PR. label Nov 5, 2018
@bflad bflad added the service/dynamodb Issues and PRs that pertain to the dynamodb service. label Nov 6, 2018
@aeschright aeschright requested a review from a team June 25, 2019 21:36
Base automatically changed from master to main January 23, 2021 00:55
@breathingdust breathingdust requested a review from a team as a code owner January 23, 2021 00:55
@gdavison gdavison self-assigned this Feb 11, 2021
@gdavison gdavison added this to the v3.28.0 milestone Feb 12, 2021
Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @178inaba. I made a few changes to it and merged the PR manually

--- PASS: TestAccAWSDynamoDbTable_streamSpecificationValidation (63.20s)
--- PASS: TestAccAWSDynamoDbTable_attributeUpdateValidation (116.53s)
--- PASS: TestAccAWSDynamoDbTable_basic (242.64s)
--- PASS: TestAccAWSDynamoDbTable_lsiNonKeyAttributes (267.30s)
--- PASS: TestAccAWSDynamoDbTable_tags (278.20s)
--- PASS: TestAccAWSDynamoDbTable_Ttl_Enabled (289.55s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateNonKeyAttributes_emptyPlan (356.93s)
--- PASS: TestAccAWSDynamoDbTable_streamSpecification (377.45s)
--- PASS: TestAccAWSDynamoDbTable_lsiUpdate (385.36s)
--- PASS: TestAccAWSDynamoDbTable_enablePitr (392.53s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateCapacity (393.50s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_GSI_PayPerRequestToProvisioned (395.66s)
--- PASS: TestAccAWSDynamoDbTable_disappears (137.51s)
--- PASS: TestAccAWSDynamoDbTable_Ttl_Disabled (353.13s)
--- PASS: TestAccAWSDynamoDbTable_disappears_PayPerRequestWithGSI (315.35s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_PayPerRequestToProvisioned (209.88s)
--- PASS: TestAccAWSDynamoDbTable_encryption (526.61s)
--- PASS: TestAccAWSDynamoDbTable_extended (318.67s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateNonKeyAttributes (569.22s)
--- PASS: TestAccAWSDynamoDbTable_attributeUpdate (875.70s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateOtherAttributes (879.16s)
--- PASS: TestAccAWSDynamoDbTable_Replica_Single (1503.61s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_GSI_ProvisionedToPayPerRequest (1518.81s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_ProvisionedToPayPerRequest (1672.09s)
--- PASS: TestAccAWSDynamoDbTable_Replica_Multiple (1763.84s)

@gdavison
Copy link
Contributor

PR merged manually

@gdavison gdavison closed this Feb 12, 2021
@178inaba 178inaba deleted the validate_dynamodb_attr branch February 12, 2021 01:23
@ghost
Copy link

ghost commented Feb 12, 2021

This has been released in version 3.28.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 for triage. Thanks!

@ghost
Copy link

ghost commented Mar 14, 2021

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 Mar 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/dynamodb Issues and PRs that pertain to the dynamodb service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants