【问题标题】:How to get JobQueue and JobDefinition name in Cloudformation template如何在 Cloudformation 模板中获取 JobQueue 和 JobDefinition 名称
【发布时间】:2018-12-07 03:40:32
【问题描述】:

在 Cloudformation 模板中,如何获取 Batch::JobDefinition 和 Batch::JobQueue 名称,以便将它们作为变量传递给 Lambda?

我尝试使用JobQueueName name QueueName 将其与!GetAtt 拉出,但更新堆栈时都失败了。使用!Ref 只会给我一个arn,我不能在JS SDK 中使用它来与批处理进行通信。

【问题讨论】:

    标签: amazon-web-services aws-sdk amazon-cloudformation


    【解决方案1】:

    AWS::Batch::JobQueue 和AWS::Batch::JobDefinition 这两个资源都只启用了函数 Ref 以返回 arn,您无法获取这些资源的任何其他值。您可以做的是使用函数Fn::Split 和Fn::Select 根据arn 获取它们的名称。例如,

    1. 对于带有 arn arn:aws:batch:us-east-1:111122223333:job-queue/HighPriority 的 JobQueue,此代码将返回 HighPriority。

      JOB_QUEUE: !Select [1 , !Split ["/", !Select [5, !Split [":", !Ref JobQueue]]]]
      
    2. 对于 JobDefinition,使用 arn arn:aws:batch:us-east-1:111122223333:job-definition/test-gpu:2,此代码将返回 test-gpu。

      JOB_DEFINITION: !Select [1 , !Split ["/", !Select [5, !Split [":", !Ref JobDefinition]]]]
      

    【讨论】:

    • 感谢 Aura,抱歉拖了这么久才说!这完美地完成了工作!
    猜你喜欢
    • 2015-01-11
    • 2015-04-27
    • 2019-11-22
    • 1970-01-01
    • 2019-05-19
    • 1970-01-01
    • 1970-01-01
    • 2018-07-21
    • 2015-12-03
    相关资源
    最近更新 更多