我正在使用cfn_pyplates来摄取yaml文件并吐出一个json文件,但这里有cfn_pyplates选项映射的问题。我在程序开始时有这段特殊的代码。现在我有一个带有“stack_role”的yaml文件,我之前使用options ['stack_role']来访问它并用于成功但现在抛出错误:
import sys
import os
sys.path.append(os.path.dirname(os.path.realpath(sys.argv[1])))
from cfn_pyplates import core, functions
import djpp
stackName = options['stack_name']
resources = dict()
抛出的错误:
> SBK-Kaul-PAR:cloudformation-private kaulk$ ./gen.sh dev/ testFile.yaml
> New python executable in python-virtualenv/bin/python Installing
> setuptools, pip...done. You are using pip version 6.1.1, however
> version 7.1.2 is available. You should consider upgrading via the 'pip
> install --upgrade pip' command. Requirement already satisfied (use
> --upgrade to upgrade): cfn-pyplates==0.4.3 in ./python-virtualenv/lib/python2.7/site-packages (from -r py_reqs.txt
> (line 3)) Traceback (most recent call last): File
> "/Users/kaulk/sandbox/cloudformation-private/python-virtualenv/bin/cfn_py_generate",
> line 10, in <module>
> sys.exit(generate()) File "/Users/kaulk/sandbox/cloudformation-private/python-virtualenv/lib/python2.7/site-packages/cfn_pyplates/cli.py",
> line 122, in generate
> pyplate = _load_pyplate(args['<pyplate>'], options_mapping) File "/Users/kaulk/sandbox/cloudformation-private/python-virtualenv/lib/python2.7/site-packages/cfn_pyplates/cli.py",
> line 40, in _load_pyplate
> exec pyplate in exec_namespace File "gen.py", line 5, in <module>
> import djpp File "/Users/kaulk/sandbox/cloudformation-private/djpp/__init__.py", line
> 1, in <module>
> from djpp import ec2, cloudformation, elb, inject File "/Users/kaulk/sandbox/cloudformation-private/djpp/cloudformation.py",
> line 1, in <module>
> import inspect, gen File "/Users/kaulk/sandbox/cloudformation-private/gen.py", line 7, in
> <module>
> stackName = options['stack_name'] NameError: name 'options' is not defined
答案 0 :(得分:0)
发现它,我正在导入此问题的另一个文件中导入选项。感谢。