cloudtools / cloudtools/troposphere

Create new object from CFN Yaml definition

Open
#1,494 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
4.9k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

Hello.
It is a question rather than an issue but unsure where to ask.
Basically, let's assume we have a YAML document somewhere and we want to integrate the CFN object it represents into a troposphere object.

If that object has a complex structure with various types expected, it doesn't work. So not sure how we could achieve the above.

Here is a snippet of what I would like to do.

```SomeTable:
Properties:
AttributeDefinitions:
- AttributeName: "currencyId"
AttributeType: "N"
- AttributeName: "currencyName"
AttributeType: "S"
KeySchema:
- AttributeName: "currencyId"
KeyType: "HASH"
- AttributeName: "currencyName"
KeyType: "RANGE"
ProvisionedThroughput:
ReadCapacityUnits: "5"
WriteCapacityUnits: "5"
TableName: "OreoCurrency"
```

and the python for it that I hoped would work is
```
import yaml
content = yaml.load()
from troposphere.dynamodb import Table
table = Table('sometable', **content['SomeTable']['Properties'])
```

At the moment I get
```
>>> table = Table('hello', **dict_['SomeTable']['Properties'])
Traceback (most recent call last):
File "", line 1, in
File "/home/john/.venv/lib64/python3.7/site-packages/troposphere/__init__.py", line 127, in __init__
self.__setattr__(k, v)
File "/home/john/.venv/lib64/python3.7/site-packages/troposphere/__init__.py", line 204, in __setattr__
self._raise_type(name, v, expected_type)
File "/home/john/.venv/lib64/python3.7/site-packages/troposphere/__init__.py", line 232, in _raise_type
expected_type))
TypeError: : hello.AttributeDefinitions is , expected []
```

Many thanks :)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.