zalando-stups / senza

Deploy immutable application stacks and create and execute AWS CloudFormation templates in a sane way

Home Page:https://pypi.python.org/pypi/stups-senza

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better error message for "create" and VPC tags

semonte opened this issue · comments

When trying to create a stack with a VPC that has no tags the user gets the following message:

senza create deploy-definition.yaml 1 0.1
Generating Cloud Formation template.. EXCEPTION OCCURRED: 'NoneType' object is not iterable
Unknown Error: 'NoneType' object is not iterable.
Please create an issue with the content of /var/folders/yd/p61l98fn2g9fffwgjs819gr1sprr6d/T/senza-traceback-xgrqlxbj

In /var/folders/yd/p61l98fn2g9fffwgjs819gr1sprr6d/T/senza-traceback-xgrqlxbj:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/senza/error_handling.py", line 76, in __call__
    self.function(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/senza/cli.py", line 663, in create
    data = create_cf_template(definition, region, version, parameter, force, parameter_file)
  File "/usr/local/lib/python3.5/site-packages/senza/cli.py", line 746, in create_cf_template
    data = evaluate(definition.copy(), args, account_info, force)
  File "/usr/local/lib/python3.5/site-packages/senza/cli.py", line 242, in evaluate
    definition = componentfn(definition, configuration, args, info, force, account_info)
  File "/usr/local/lib/python3.5/site-packages/senza/components/stups_auto_configuration.py", line 31, in component_stups_auto_configuration
    vpc_id = configuration.get('VpcId', account_info.VpcID)
  File "/usr/local/lib/python3.5/site-packages/senza/cli.py", line 329, in VpcID
    vpc = ec2.get_default_vpc()
  File "/usr/local/lib/python3.5/site-packages/senza/manaus/ec2.py", line 71, in get_default_vpc
    return EC2VPC.from_boto_vpc(vpc)
  File "/usr/local/lib/python3.5/site-packages/senza/manaus/ec2.py", line 41, in from_boto_vpc
    return cls(vpc.vpc_id, vpc.is_default, vpc.tags)
  File "/usr/local/lib/python3.5/site-packages/senza/manaus/ec2.py", line 22, in __init__
    self.tags = OrderedDict([(t['Key'], t['Value']) for t in tags])  # type: Dict[str, str]
TypeError: 'NoneType' object is not iterable

The error message should be more descriptive.

The error should not even pop up --- tags are optional.