CloudFormation ECS TaskDefinition: correct type/processing for Parameter for EntryPoint in YAML Template

0

I want to be able to accept an optional Parameter for the EntryPoint of a AWS::ECS::TaskDefinition -> ContainerDefinitions[], in a YAML CloudFormation template. This is a little tricky, since ECS wants a comma-separated list for this, e.g. /bin/bash,-c,echo hello, but in the CloudFormation template, it appears to be an array of string.

What is the best type to define for a EntryPoint Parameter in this case? The error I'm currently trying to avoid is:

Resource handler returned message: "Model validation failed (#/ContainerDefinitions/0/EntryPoint/0: expected type: String, found: JSONArray 

I've defined the parameter currently as: CommaDelimitedList:

  EntryPoint:
    Type: CommaDelimitedList
    Description: "Task entrypoint (Optional - image default is script /start)"

... which is yielding a JSONArray?, but I think I need an array of strings, which I'm not getting from:

      ContainerDefinitions:      
          EntryPoint:
            - !If
              - EntryPointProvided
              - !Ref EntryPoint
              - !Ref 'AWS::NoValue'

What is the best type to use and the most direct processing to get to the type required in the template and by ECS? Or a current fix for the JSONArray would be fine. Thanks!

1개 답변
1
수락된 답변

I believe you want to try something like below to avoid the error you are seeing. This will treat the result of the If function as the input for the EntryPoint property as opposed to an list of strings within a outer list.

Note that the ‘-‘ preceding the if function has been removed.

      ContainerDefinitions:      
          EntryPoint: !If
              - EntryPointProvided
              - !Ref EntryPoint
              - !Ref 'AWS::NoValue'
답변함 2년 전
  • Spot on, perfect answer thanks Shane - clearly I missed that I was wrapping the dereference with that extra -. With this fix I am now able to pass arrays via comma-separated strings for both EntryPoint and Command via template parameters, which is awesome.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠