1
votes

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.

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"

Would the VPCId line be something like

VPCId: {Ref: VPC}

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?

1

1 Answers

1
votes

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" ] }

from the functions docs and the CloudFormation docs

A similar approach should also work for the subnets.