Cloudformation error: Template validation error: Template error: Fn::Select cannot select nonexistent value at index 2

Cloudformation error: Template validation error: Template error: Fn::Select cannot select nonexistent value at index 2

在参数里,我用的是这个

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

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

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

但我收到错误:模板验证错误:模板错误:Fn::Select 不能 select 索引 2

处不存在的值

为什么我会收到此错误

索引从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]