0

I've got a CloudFormation template that's launching a central server instance using OpsWorks (so I'm defining an OpsWorks::App, OpsWorks::Instance, OpsWorks::Layer and OpsWorks::Stack). Elsewhere in the CF template it is launching an EC2 instance for a slave node, which needs to know the IP address / DNS name of the central server so it initiate communications with the server. The Opsworks server gets an Elastic IP, but not one I explicitly give it, instead the OpsWorks layer has AutoAssignElasticIps set to true.

If it were one EC2 instance referencing another, I'd simply use { "Fn::GetAtt": [ "MyServerInstance", "PublicDnsName" ] } to get the address. But an AWS::OpsWorks::Instance is not the same as an AWS::EC2::Instance (even though it does create an EC2 instance), and so template validation fails with:

Template validation error: Template error: resource MyServerInstance does not support attribute type PublicDnsName in Fn::GetAtt

Is there another way to get the address of the launched OpsWorks instance? Or is it possible to get an AWS::EC2::Instance from an AWS::OpsWorks::Instance such that I can then ask it for the PublicDnsName?

MrCranky
  • 91
  • 6

2 Answers2

1

That is not possible via CloudFormation, you must use a cookbook on the OpsWorks layer.

I use this one: https://github.com/opscode-cookbooks/aws.

GregL
  • 9,030
  • 2
  • 24
  • 35
0

You could also install aws-cli and a Chef recipe and parse the details from there (I used this method to bootstrap a an EC2 into a NAT for the VPC). This assumes you're running "locally" or you would need to run from another machine...

J. Lawson
  • 86
  • 10