微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Elastic Beanstalk:如何使用 .ebextensions 从另一个 Cloudformation 堆栈导入 VPCId?

如何解决Elastic Beanstalk:如何使用 .ebextensions 从另一个 Cloudformation 堆栈导入 VPCId?

是否可以使用 AWS Elastic Beanstalk 中 Fn:ImportValue 中的 option_settings 从其他 Cloudformation 堆栈中导入 VPCId 的值?

或者此时必须对值进行硬编码?任何指针将不胜感激!

这是一个有效的 .ebextensions/config,它部署成功: 有关更多上下文,该应用程序是一个简单的 node.js express 服务器,我正在使用 eb cli

部署堆栈
#.ebextensions/vpc.config
option_settings:
  aws:ec2:vpc:
    ELBScheme: internal
    VPCId: vpc-0620a64be983c807a
    subnets: "subnet-0b2e7f79bdd53a4da,subnet-0f0f6471dc6130f0a,subnet-0ce654446fd42509a"
    ELBsubnets: "subnet-0b2e7f79bdd53a4da,subnet-0ce654446fd42509a"
    AssociatePublicIpAddress: true

这是将 VPCId 导出到另一个 cloudformation 堆栈中且值为 vpc-0620a64be983c807a 的损坏示例:

option_settings:
  aws:ec2:vpc:
    ELBScheme: internal
    VPCId: { "Fn::ImportValue" : "VPCId" }
    subnets: "subnet-0b2e7f79bdd53a4da,subnet-0ce654446fd42509a"
    AssociatePublicIpAddress: true

这是错误代码,在弹性 beanstalk 包上传到 AWS 后,它似乎没有插入 vpcID

2021-01-19 10:36:59    ERROR   "option_settings" in one of the configuration files Failed validation. More details to follow.
2021-01-19 10:36:59    ERROR   Invalid option value: '["subnet-0ce654446fd425098","subnet-0b2e7f79bdd53a4df","subnet-0f0f6471dc6130f0c"]' (Namespace: 'aws:ec2:vpc',OptionName: 'subnets'): Specify the VPC ID and make sure all subnets exist.
2021-01-19 10:37:00    ERROR   Invalid option value: 'subnet-0b2e7f79bdd53a4df,subnet-0f0f6471dc6130f0c,subnet-0ce654446fd425098' (Namespace: 'aws:ec2:vpc',OptionName: 'ELBsubnets'): Specify the VPC ID and make sure all subnets exist.
2021-01-19 10:37:00    ERROR   Failed to launch environment.

更新: 建议使用反引号和引号,但它似乎在 VPC 查找中按字面意思处理整个字符串

2021-01-19 11:31:05    ERROR   The VPC '`{ "fn::importvalue" :"vpcid" }`' does not exist.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。