mal*_*ana 3 yaml aws-cloudformation aws-glue
您可以通过参数将参数传递给 AWS Glue 作业--arguments(请参阅此处)。
该CloudFormation文档说DefaultArguments是“UTF-8字符串到UTF-8字符串键值对”,他们的类型是“JSON对象”。由于 YAML 是 JSON 的超集,我希望能够在 (YAML) CloudFormation 模板中传递这样的参数:
DefaultArguments:
"--arguments": {"--test_argument": "foo"}
Run Code Online (Sandbox Code Playgroud)
但是,它会在 CloudFormation 部署期间引发此错误:
属性验证失败:[属性值 {/DefaultArguments/--arguments=} 与类型 {String} 不匹配]
如何正确指定值?
传递多个参数的正确方法是
DefaultArguments:
"--argument1": value1
"--argument2": value2
Run Code Online (Sandbox Code Playgroud)
然后在作业中访问它们(例如在 Python 中),如下所示:
from awsglue.utils import getResolvedOptions
args = getResolvedOptions(sys.argv, ['argument1', 'argument2'])
print args['argument1']
print args['argument2']
Run Code Online (Sandbox Code Playgroud)
让我感到困惑的是,使用 AWS CLI 传递参数时,您使用了显式--arguments='--argument1="value1"'结构,但在 CloudFormation 中,您一个接一个地指定参数。
| 归档时间: |
|
| 查看次数: |
3670 次 |
| 最近记录: |