aws-cloudformation / aws-cloudformation/cloudformation-cli-python-plugin

When using OOTB CFN Test is broken with 'Tags' attribute on generated class

Đang mở
#248 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
107
Fork
46
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Assuming same steps in https://github.com/aws-cloudformation/cloudformation-cli-python-plugin/issues/247, using the workaround to get by the current cryptography issue.

After trying to run one test `cfn test -- -k contract_create_delete`, it fails with:
```
Traceback (most recent call last):
File "/var/task/cloudformation_cli_python_lib/resource.py", line 165, in _cast_resource_request
return UnmodelledRequest(
File "/var/task/cloudformation_cli_python_lib/utils.py", line 156, in to_modelled
desiredResourceState=model_cls._deserialize(self.desiredResourceState),
File "/var/task/dd_dd_dd/models.py", line 74, in _deserialize
Tags=set_or_none(json_data.get("Tags")),
File "/var/task/dd_dd_dd/models.py", line 30, in set_or_none
return set(value)
TypeError: unhashable type: 'dict'
```

Root cause and fix:

- The default JSON makes Tags a list/array of Tag object (`"#/definitions/Tag"`). A tag object then has a key and value attribute. This is not hashable
- Fix(probably) change [this line](https://github.com/aws-cloudformation/cloudformation-cli-python-plugin/blob/master/python/rpdk/python/templates/models.py#L30) to a frozen set: `return frozenset(value)`
- Also same change for [hooks](https://github.com/aws-cloudformation/cloudformation-cli-python-plugin/blob/master/python/rpdk/python/templates/hook_models.py#L27)?
- Maybe [this](https://github.com/aws-cloudformation/cloudformation-cli-python-plugin/blob/master/python/rpdk/python/templates/target_model.py#L27) one too.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.