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

resource/aws_appautoscaling_policy: Support importing policies for DynamoDB table indexes #11232

Merged
merged 2 commits into from
Apr 6, 2020
Merged

resource/aws_appautoscaling_policy: Support importing policies for DynamoDB table indexes #11232

merged 2 commits into from
Apr 6, 2020

Conversation

camhux
Copy link

@camhux camhux commented Dec 10, 2019

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Release note for CHANGELOG:

* resource/aws_appautoscaling_policy: Fix error when attempting to import a policy for a DynamoDB table index

The code that splits up a DynamoDB resource ID when importing an aws_appautoscaling_policy doesn't account for resource IDs of table indexes, resulting in an error from the AWS API when the /index/ segment is interpreted as the scaling dimension:

* import aws_appautoscaling_policy.dynamodb_read_policy result: query/dynamodb:index:ReadCapacityUnits/DynamoDBReadCapacityUtilization:table/MyTable/index/MyIndex: aws_appautoscaling_policy.dynamodb_read_policy: Failed to read scaling policy: Error retrieving scaling policies: ValidationException: 1 validation error detected: Value 'index' at 'scalableDimension' failed to satisfy constraint: Member must satisfy enum value set: [dynamodb:table:ReadCapacityUnits, dynamodb:index:ReadCapacityUnits, rds:cluster:ReadReplicaCount, comprehend:document-classifier-endpoint:DesiredInferenceUnits, elasticmapreduce:instancefleet:SpotCapacity, lambda:function:ProvisionedConcurrency, appstream:fleet:DesiredCapacity, dynamodb:index:WriteCapacityUnits, elasticmapreduce:instancefleet:OnDemandCapacity, rds:cluster:Capacity, dynamodb:table:WriteCapacityUnits, custom-resource:ResourceType:Property, sagemaker:variant:DesiredInstanceCount, ec2:spot-fleet-request:TargetCapacity, elasticmapreduce:instancegroup:InstanceCount, ecs:service:DesiredCount]
        status code: 400, request id: 223fb266-1b98-11ea-a615-c57387cdd7b8

This PR changes the import validation code to detect when a resource ID appears to be an index ID and handle this case correctly.

Output from acceptance testing:

$ make testacc TESTARGS="-run=TestAccAWSAppautoScalingPolicy_dynamoDb"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -count 1 -parallel 20 -run=TestAccAWSAppautoScalingPolicy_dynamoDb -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSAppautoScalingPolicy_dynamoDb
=== PAUSE TestAccAWSAppautoScalingPolicy_dynamoDb
=== CONT  TestAccAWSAppautoScalingPolicy_dynamoDb
--- PASS: TestAccAWSAppautoScalingPolicy_dynamoDb (31.01s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       31.992s
testing: warning: no tests to run
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws/internal/flatmap      0.032s [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags 0.078s [no tests to run]
...

@camhux camhux requested a review from a team December 10, 2019 22:51
@ghost ghost added needs-triage Waiting for first response or review from a maintainer. size/XS Managed by automation to categorize the size of a PR. service/applicationautoscaling tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Dec 10, 2019
@bflad bflad added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Apr 6, 2020
@bflad bflad self-assigned this Apr 6, 2020
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this, @camhux 🚀 Please note that we also added an acceptance test to ensure the end-to-end behavior:

--- PASS: TestAccAWSAppautoScalingPolicy_dynamodb_index (46.12s)

@bflad bflad added this to the v2.57.0 milestone Apr 6, 2020
@bflad bflad linked an issue Apr 6, 2020 that may be closed by this pull request
@bflad bflad merged commit b410bc5 into hashicorp:master Apr 6, 2020
bflad added a commit that referenced this pull request Apr 6, 2020
@ghost
Copy link

ghost commented Apr 10, 2020

This has been released in version 2.57.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!

twitty-rival pushed a commit to twitty-rival/terraform-provider-aws that referenced this pull request May 6, 2020
@ghost
Copy link

ghost commented May 7, 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 and limited conversation to collaborators May 7, 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. size/XS Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot import aws_appautoscaling_policy for DynamoDB secondary indexes
2 participants