Terraform-provider-aws: Can the Regex for importing aws_appautoscaling_policy be relaxed to allow `/` symbols.

Created on 12 Apr 2019  ·  4Comments  ·  Source: hashicorp/terraform-provider-aws

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 "me too" comments, 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 Version

Terraform v0.11.13
+ provider.aws v2.6.0
+ provider.cloudflare v1.12.0
+ provider.datadog v1.7.0
+ provider.template v2.1.1

Affected Resource(s)

  • aws_appautoscaling_policy

Panic Output

Error: module.data_global.module.sisyphus_autoscaling_usw2.aws_appautoscaling_policy.dynamodb_table_read_policy (import id: dynamodb/table/sisyphus_userroles_with_team/dynamodb:table:ReadCapacityUnits/dynamodb:table:ReadCapacityUnits/table/sisyphus_userroles_with_team): 1 error(s) occurred:

* import module.data_global.module.test_autoscaling_usw2.aws_appautoscaling_policy.dynamodb_table_read_policy result: test: aws_appautoscaling_policy.dynamodb_table_read_policy: Failed to read scaling policy: Error retrieving scaling policies: ValidationException: 1 validation error detected: Value 'table' at 'scalableDimension' failed to satisfy constraint: Member must satisfy enum value set: [dynamodb:table:ReadCapacityUnits, dynamodb:index:ReadCapacityUnits, rds:cluster:ReadReplicaCount, elasticmapreduce:instancefleet:SpotCapacity, 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]

Expected Behavior

  • it should have imported successfully

Actual Behavior

the required id <service-namespace>/<resource-id>/<scalable-dimension>/<policy-name> doesn't validate correctly if policy-name also includes /

Steps to Reproduce

  • terraform import module.data_global.module.sisyphus_autoscaling_usw2.aws_appautoscaling_policy.dynamodb_table_read_policy dynamodb/table/test/dynamodb:table:ReadCapacityUnits/DynamoDBReadCapacityUtilization:table/test
bug servicapplicationautoscaling

Most helpful comment

I'm facing exactly the same issue.

According to the documentation, the name of the policy of a DynamoDB table will always be in a format similar to: DynamoDBReadCapacityUtilization:table/tableName Which means the issue takes part of the policy name as a scaling policy.

I found the code is treating dynamoDB target resource id as ECS/RDS (with no slashes (/) in the policy name), and it interpolates in a wrong way. This might work for ECS and RDS scaling, but it fails for DynamoDB.

Also I would propose a couple of changes to the defect:

  • There's no regex, I might change the title of the bug to something like Importing aws_appautoscaling_policy fails for DynamoDB policy
  • Adding the label:bug
  • Adding the label:service/applicationautoscaling

I sent pull request #8397 that fixes this issue. Let's see if it's accepted :-)

All 4 comments

I'm facing exactly the same issue.

According to the documentation, the name of the policy of a DynamoDB table will always be in a format similar to: DynamoDBReadCapacityUtilization:table/tableName Which means the issue takes part of the policy name as a scaling policy.

I found the code is treating dynamoDB target resource id as ECS/RDS (with no slashes (/) in the policy name), and it interpolates in a wrong way. This might work for ECS and RDS scaling, but it fails for DynamoDB.

Also I would propose a couple of changes to the defect:

  • There's no regex, I might change the title of the bug to something like Importing aws_appautoscaling_policy fails for DynamoDB policy
  • Adding the label:bug
  • Adding the label:service/applicationautoscaling

I sent pull request #8397 that fixes this issue. Let's see if it's accepted :-)

The fix to the aws_appautoscaling_policy resource has been merged and will be released with version 2.20.0 of the Terraform AWS provider.

The fix to the aws_appautoscaling_policy resource, has been released in version 2.20.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 resource, please create a new GitHub issue following the template for triage. Thanks!

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!

Was this page helpful?
0 / 5 - 0 ratings