考虑一下aws批处理作业定义:
MyJobDefinition:
Type: "AWS::Batch::JobDefinition"
Properties:
Type: container
Parameters: {}
JobDefinitionName: "my-job-name"
ContainerProperties:
Command:
- "java"
- "-jar"
- "my-application-SNAPSHOT.jar"
- "--param1"
- "Ref::param1"
- "--param2"
- "Ref::param2"
要调用哪个结果:
java -jar my-application-SNAPSHOT.jar --param1 someValue1 --param2 someValue2
如何更改作业定义以使其喜欢(注意等号):
java -jar my-application-SNAPSHOT.jar --param1=someValue1 --param2=someValue2
请注意Ref::param1
它不是cloudformation模板参数,而是aws batch job params。
答案 0 :(得分:0)
据我了解,通过查找Ref ::前缀来替换AWS批处理参数。我只能找到一个thread,他们尝试在较大的字符串中使用参数,并且可以正常工作。
鉴于此,以下应该起作用
MyJobDefinition:
Type: "AWS::Batch::JobDefinition"
Properties:
Type: container
Parameters: {}
JobDefinitionName: "my-job-name"
ContainerProperties:
Command:
- "java"
- "-jar"
- "my-application-SNAPSHOT.jar"
- "--param1=Ref::param1"
- "--param2=Ref::param2"
答案 1 :(得分:-1)
使用评估模板中表达式的!Sub
:
MyJobDefinition:
Type: "AWS::Batch::JobDefinition"
Properties:
Type: container
Parameters: {}
JobDefinitionName: "my-job-name"
ContainerProperties:
Command:
- "java"
- "-jar"
- "my-application-SNAPSHOT.jar"
- !Sub "--param1=${param1}"
- !Sub "--param2=${param2}"