aws-cloudformation / cloudformation-cli-go-plugin

The CloudFormation Provider Development Toolkit Go Plugin allows you to autogenerate Go code based on an input schema.
52 stars 31 forks source link

Error with resource property types during contract tests #201

Closed vpuli closed 2 years ago

vpuli commented 2 years ago

Hi,

I am running contract tests locally for my resource AWS::IVS::RecordingConfiguration, and the contract tests are failing with the following error:

================ ERRORS ==========================================
________________________ ERROR at setup of contract_create_create _________________________
../../../build/AWSCloudFormationResourceProvidersIVS/AWSCloudFormationResourceProvidersIVS-1.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/tmp/brazil-path/[AWSCloudFormationRPDKGoPluginTool-1.1]run.runtimefarm/lib/python3.6/site-packages/rpdk/core/contract/resource_client.py:422: in compare
    assert inputs[key] == outputs[key], assertion_error_message
E   AssertionError: All properties specified in the request MUST be present in the model returned, and they MUST match exactly, with the exception of properties defined as writeOnlyProperties in the resource schema
The above exception was the direct cause of the following exception:
../../../build/AWSCloudFormationResourceProvidersIVS/AWSCloudFormationResourceProvidersIVS-1.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/tmp/brazil-path/[AWSCloudFormationRPDKGoPluginTool-1.1]run.runtimefarm/lib/python3.6/site-packages/rpdk/core/contract/resource_client.py:410:
 in compare
    self.compare(inputs[key], outputs[key], new_path)
../../../build/AWSCloudFormationResourceProvidersIVS/AWSCloudFormationResourceProvidersIVS-1.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/tmp/brazil-path/[AWSCloudFormationRPDKGoPluginTool-1.1]run.runtimefarm/lib/python3.6/site-packages/rpdk/core/contract/resource_client.py:426: in compare
    raise AssertionError(assertion_error_message) from exception
E   AssertionError: All properties specified in the request MUST be present in the model returned, and they MUST match exactly, with the exception of properties defined as writeOnlyProperties in the resource schema

I am providing an Input file inputs_1_create.json as such: { "Name": "CreateTestRecordingConfiguration", "DestinationConfiguration": { "S3": { "BucketName": "{{ResourceProviderBucket}}" } }, "Tags": [ { "Key": "organization", "Value": "aws" } ], "ThumbnailConfiguration":{ "RecordingMode": "INTERVAL", "TargetIntervalSeconds": 30 }

However the request and response during the Contract test handler calls do not match and result in an error, as the response returns the TargetIntervalSeconds as a string, while in the request it is a integer.

{ "callbackContext": null, "action": "CREATE", "requestData": { "resourceProperties": { "Name": "CreateTestRecordingConfiguration", "DestinationConfiguration": { "S3": { "BucketName": "cfn-recording-configuratio-resourceproviderbucket-zv1a76sbfla7" } }, "Tags": [ { "Key": "organization", "Value": "aws" } ], "ThumbnailConfiguration": { "RecordingMode": "INTERVAL", "TargetIntervalSeconds": 30 } }, "previousResourceProperties": null, "logicalResourceId": "aec1a77f-7db4-4fca-bb04-e0400be41d49" }, "region": "us-east-1", "awsAccountId": "956482054022", "bearerToken": "aec1a77f-7db4-4fca-bb04-e0400be41d49" } [2022-01-21T22:22:48Z] DEBUG - Received response {'message': 'Create in progress', 'status': 'IN_PROGRESS', 'resourceModel': {'Arn': 'arn:aws:ivs:us-east-1:956482054022:recording-configuration/LOgM3IpQmPfJ', 'Name': 'CreateTestRecordingConfiguration', 'State': 'CREATING', 'DestinationConfiguration': {'S3': {'BucketName': 'cfn-recording-configuratio-resourceproviderbucket-zv1a76sbfla7'}}, 'Tags': [{'Key': 'organization', 'Value': 'aws'}], 'ThumbnailConfiguration': {'RecordingMode': 'INTERVAL', 'TargetIntervalSeconds': '30'}}, 'bearerToken': 'aec1a77f-7db4-4fca-bb04-e0400be41d49', 'resourceModels': None, 'callbackContext': {'Arn': 'arn:aws:ivs:us-east-1:956482054022:recording-configuration/LOgM3IpQmPfJ'}, 'callbackDelaySeconds': 5}

Is there any integer to string conversion in the contract test code that could cause this? In the resource scheme, the TargetIntervalSeconds field is defined as type: integer

msummers-nr commented 10 months ago

@vpuli What was the resolution to this issue? I'm currently seeing the same problem.