tomwwright / littleorange

Minimalist AWS multi-account cloud leveraging CloudFormation and Lambda.
GNU General Public License v3.0
4 stars 1 forks source link

`cfn test` fails with an "unexpected keyword 'region'" error #3

Open tomwwright opened 3 years ago

tomwwright commented 3 years ago
cloudformation_cli_python_lib.exceptions.InternalFailure: __init__() got an unexpected keyword argument 'region/awsPartition/awsAccountId' (TypeError)

Caused by changes to the contract test request format upstream https://github.com/aws-cloudformation/cloudformation-cli/pull/502

Partial fix applied here https://github.com/aws-cloudformation/cloudformation-cli-python-plugin/pull/107/files, but cloudformation-cli-python-lib hasn't released as v2.1.0 on pypi yet

Solution for now is to monkey patch dataclass in build/cloudformation_cli_python_lib/utils.py to expect the extra fields:

@dataclass
class UnmodelledRequest:
  clientRequestToken: str
  desiredResourceState: Optional[Mapping[str, Any]] = None
  previousResourceState: Optional[Mapping[str, Any]] = None
  logicalResourceIdentifier: Optional[str] = None
  nextToken: Optional[str] = None       
  region: Optional[str] = None          # <--- add these
  awsAccountId: Optional[str] = None    # <---
  awsPartition: Optional[str] = None    # <---