Is it possible to import the value for VPCId from other Cloudformation stacks using Fn:ImportValue in the option_settings in AWS Elastic Beanstalk?
Or do the values have to be hardcoded in at this point? Any pointers would be really appreciated!
This is a working .ebextensions/config, it deploys successfully:
For more context, the application is a simple node.js express server and I am deploying the stack using the 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-0f0f6471dc6130f0a,subnet-0ce654446fd42509a"
AssociatePublicIpAddress: true
This is the broken example with VPCId exported in another cloudformation stack with the value of vpc-0620a64be983c807a:
option_settings:
aws:ec2:vpc:
ELBScheme: internal
VPCId: { "Fn::ImportValue" : "VPCId" }
Subnets: "subnet-0b2e7f79bdd53a4da,subnet-0f0f6471dc6130f0a,subnet-0ce654446fd42509a"
ELBSubnets: "subnet-0b2e7f79bdd53a4da,subnet-0f0f6471dc6130f0a,subnet-0ce654446fd42509a"
AssociatePublicIpAddress: true
This is the error code, it seems like it isn't interpolating the vpcID after the elastic beanstalk bundle has been uploaded to AWS
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.
Update: Backticks and Quotations were suggested, however it seems like it then treats the whole string literally in the VPC lookup
2021-01-19 11:31:05 ERROR The VPC '`{ "fn::importvalue" :"vpcid" }`' does not exist.