Cloudformation错误:模板验证错误:模板错误:Fn :: Select无法在索引2处选择不存在的值

时间:2018-04-30 06:58:46

标签: amazon-web-services amazon-cloudformation

在参数中,我正在使用此

envGOSBasicAuthentication:
    Description: "xyz"
    Type: CommaDelimitedList
    Default: "username, password"

在配置模板中,我使用下面的代码:

OptionSettings:
         - Namespace: 'aws:elasticbeanstalk:application:environment'
           OptionName: PASSWORD
           Value: !Select [2, !Ref envGOSBasicAuthentication]

但我收到错误:模板验证错误:模板错误:Fn :: Select无法在索引2处选择不存在的值

为什么我收到此错误

1 个答案:

答案 0 :(得分:0)

索引以0开头。

来自AWS文档:This must be a value from zero to N-1, where N represents the number of elements in the array.(请参阅https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-select.html)。

因此,请尝试以下方法从envGOSBasicAuthentication获取密码。

OptionSettings:
- Namespace: 'aws:elasticbeanstalk:application:environment'
  OptionName: PASSWORD
  Value: !Select [1, !Ref envGOSBasicAuthentication]