如何将AWS资源ID插入应用程序配置文件 [英] How to insert AWS resource IDs into application configuration files
问题描述
我正在遵循有关将HA Wordpress网站部署到Elastic Beanstalk的AWS指南,其中包括使用eb-php-wordpress
扩展名.该过程需要在部署应用程序之前用已知的资源ID编辑几个配置文件.
I'm following the AWS guide for deploying an HA Wordpress site to Elastic Beanstalk which includes using the eb-php-wordpress
extension. The process requires editing a couple of configuration files with known resource IDs prior to deploying the application.
尤其是,说明说要使用VPC ID和子网ID编辑efs-create.config
文件.该文件尤其有助于设置AWS::ElasticBeanstalk::Environment
资源的OptionSettings
属性.因此,我怀疑我应该只能使用Ref:
引用它.这是正确的,但是由于VPC将由另一个文件创建,并且EB环境Cloudformation堆栈是在VPC堆栈旁边而不是内部"创建的?我必须使用Fn::
调用来获取信息吗?
In particular, the instructions say to edit the efs-create.config
file with a VPC ID, and Subnet IDs. The file, among other things, helps set the OptionSettings
property of the AWS::ElasticBeanstalk::Environment
resource. For this reason, I suspect I should just be able to reference it with Ref:
. Is this correct, though since the VPC would be created by another file and the EB environment Cloudformation stack is created next to the VPC stack rather than "inside" it? Would I have to use a Fn::
call to get the information?
我正在使用的配置文件部分如下所示:
The section of the configuration file I'm working with looks like this:
option_settings:
aws:elasticbeanstalk:customoption:
EFSVolumeName: "EB-EFS-Volume"
VPCId: "vpc-XXXXXXXX"
## Subnet Options
SubnetA: "subnet-XXXXXXXX"
SubnetB: "subnet-XXXXXXXX"
SubnetC: "subnet-XXXXXXXX"
SubnetD: "subnet-XXXXXXXX"
VPCId行是否会像
Would the VPCId line be something like
VPCId: {Ref: VPC}
在哪里VPC
是我创建的VPC资源的名称?或者,更简单地说,如果我坚持使用默认VPC的VPC ID,该如何引用呢?
Where VPC
is the name of the VPC resource that I've created? Or, more simply, how would I reference the VPC ID of the default VPC if I stick with that?
推荐答案
您应该能够使用Ref
来获取弹性beantalk的各种ID 文档.但是,VPC不是这些命名资源(即具有逻辑ID的资源)之一,而是 是其中一种命名资源的属性.逻辑ID为AWSEBSecurityGroup
,属性为VpcId
,因此您应该可以使用GetAtt
来获取它:
You should be able to use Ref
to get the various IDs of the elastic beanstalk named resources, according to the docs. However, the VPC is not one of these named resources (ie those with a logical ID), but is a property of one of the named resources, in this case, the logical ID is AWSEBSecurityGroup
and the property is VpcId
so you should be able to get it instead using GetAtt
:
{ "Fn::GetAtt" : [ "AWSEBSecurityGroup", "VpcId" ] }
类似的方法也应适用于子网.
A similar approach should also work for the subnets.
这篇关于如何将AWS资源ID插入应用程序配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!