Terraform v0.11.13
+ provider.aws v2.6.0
+ provider.cloudflare v1.12.0
+ provider.datadog v1.7.0
+ provider.template v2.1.1
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]
the required id <service-namespace>/<resource-id>/<scalable-dimension>/<policy-name> doesn't validate correctly if policy-name also includes /
terraform import module.data_global.module.sisyphus_autoscaling_usw2.aws_appautoscaling_policy.dynamodb_table_read_policy dynamodb/table/test/dynamodb:table:ReadCapacityUnits/DynamoDBReadCapacityUtilization:table/testI'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!
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/tableNameWhich means the issue takes part of thepolicy nameas ascaling 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.
I sent pull request #8397 that fixes this issue. Let's see if it's accepted :-)