Fixed validation on custom-resource in applicationautoscaling (#4026)

* Added ResourceTypeExceptions

* Added test for custom-resource

Co-authored-by: Phil Sheets <p.sheets@fetchrewards.com>
This commit is contained in:
psheets 2021-06-23 11:57:09 -04:00 committed by GitHub
parent 6fb05d6453
commit b9a42816bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 29 additions and 15 deletions

View File

@ -8,6 +8,11 @@ import time
import uuid import uuid
@unique
class ResourceTypeExceptionValueSet(Enum):
RESOURCE_TYPE = "ResourceType"
@unique @unique
class ServiceNamespaceValueSet(Enum): class ServiceNamespaceValueSet(Enum):
APPSTREAM = "appstream" APPSTREAM = "appstream"
@ -230,8 +235,12 @@ def _target_params_are_valid(namespace, r_id, dimension):
if dimension is not None: if dimension is not None:
try: try:
valid_dimensions = [d.value for d in ScalableDimensionValueSet] valid_dimensions = [d.value for d in ScalableDimensionValueSet]
resource_type_exceptions = [r.value for r in ResourceTypeExceptionValueSet]
d_namespace, d_resource_type, scaling_property = dimension.split(":") d_namespace, d_resource_type, scaling_property = dimension.split(":")
if d_resource_type not in resource_type_exceptions:
resource_type = _get_resource_type_from_resource_id(r_id) resource_type = _get_resource_type_from_resource_id(r_id)
else:
resource_type = d_resource_type
if ( if (
dimension not in valid_dimensions dimension not in valid_dimensions
or d_namespace != namespace or d_namespace != namespace

View File

@ -244,6 +244,11 @@ def test_register_scalable_target_resource_id_variations():
"keyspace/mykeyspace/table/mytable", "keyspace/mykeyspace/table/mytable",
"cassandra:table:ReadCapacityUnits", "cassandra:table:ReadCapacityUnits",
), ),
(
"custom-resource",
"https://test-endpoint.amazon.com/ScalableDimension/test-resource",
"custom-resource:ResourceType:Property",
),
] ]
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION) client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)