我正在遵循有关将HA Wordpress网站部署到Elastic Beanstalk的AWS指南,其中包括使用eb-php-wordpress扩展。该过程需要在部署应用程序之前用已知的资源ID编辑几个配置文件。
尤其是,说明说要使用VPC ID和子网ID编辑efs-create.config文件。除其他事项外,该文件还有助于设置AWS :: ElasticBeanstalk :: Environment资源的OptionSettings属性。感谢danimal,我现在知道如何使用Fn::GetAtt
将VpcId拉入文件:
option_settings:
aws:elasticbeanstalk:customoption:
EFSVolumeName: "EB-EFS-Volume"
VPCId: { "Fn::GetAtt" : [ "AWSEBSecurityGroup", "VpcId" ] }
## Subnet Options
SubnetA: "subnet-XXXXXXXX"
SubnetB: "subnet-XXXXXXXX"
SubnetC: "subnet-XXXXXXXX"
SubnetD: "subnet-XXXXXXXX"
现在,我的障碍是添加那些子网ID。我尝试将相同但略微扩展的概念应用于AWSEBV2LoadBalancer
资源以拉出Subnets数组,但出现错误。
代码:
SubnetA: { "Fn::Select" : [ "0", { "Fn::GetAtt" : [ "AWSEBV2LoadBalancer", "Subnets" ] } ] }
SubnetB: { "Fn::Select" : [ "1", { "Fn::GetAtt" : [ "AWSEBV2LoadBalancer", "Subnets" ] } ] }
SubnetC: { "Fn::Select" : [ "2", { "Fn::GetAtt" : [ "AWSEBV2LoadBalancer", "Subnets" ] } ] }
SubnetD: { "Fn::Select" : [ "3", { "Fn::GetAtt" : [ "AWSEBV2LoadBalancer", "Subnets" ] } ] }
错误:
Service:AmazonCloudFormation, Message:Template error: resource AWSEBV2LoadBalancer does not support attribute type Subnets in Fn::GetAtt
我发现这很奇怪,因为生成的模板在该资源下显示了Subnets
:
"AWSEBV2LoadBalancer": {
"Properties": {
"SecurityGroups": [
{
"Ref": "AWSEBLoadBalancerSecurityGroup"
}
],
"Subnets": [
"subnet-0ec0699f08ff45e6e",
"subnet-0a4fec611d42b062f",
"subnet-09a4c28b8f330c0c3",
"subnet-0ea8d69e46ce87afc"
]
},
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer"
},
我还尝试使用Subnets: { "Fn::GetAtt" : [ "AWSEBV2LoadBalancer", "Subnets" ]
分配数组,然后在其上使用Fn::Select
和Ref
:SubnetA: { "Fn::Select" : [ "0", [ "Ref" : "Subnets" ] ] }
,但这会产生自己的错误:
Service:AmazonCloudFormation, Message:Template format error: Unresolved resource dependencies [Subnets] in the Resources block of the template
如何提取数组并将每个元素分配给不同的资源?
答案 0 :(得分:0)
根据文档(按日),这是不可能的。让我想知道别人是如何做到的,因为我无法想象我是第一个尝试的人。