I have a stack generated by AWS CloudFormation that includes an EC2 instance (running Ubuntu 14.04) and an RDS (database) instance. They are both inside a VPC, which includes a puppet master (not as part of the cloud formation stack):

----------------- VPC --------------------
+-----+       +-----+    +---------------+
| EC2 | <---> | RDS |    | Puppet master |
+-----+       +-----+    +---------------+

I want to puppetize the EC2 node, writing a config for the webserver and the application including the DB connection info, part of which is the internal hostname of the RDS instance.

The question is how can I get the puppetmaster to compile the template for the application configuration if it needs to know the internal hostname of the RDS node.

I am new to most of these technologies, especially CloudFormation and Puppet. So far I have thought of a few solutions, but wanted some guidance and wondered if I had missed something.

  • Use UserData in the CloudFormation template to make it available to the EC2 instance so it can add it to Facter on the EC2 puppet agent. This seems wrong as the EC2 node is reporting to puppet about another machine.
  • Use the EC2 API on puppet master to inspect the RDS nodes in the VPC and find the correct one (via a tag perhaps?) but i'm not sure how to get Puppet to call the EC2 APIs and insert a value from it into a template

1 Answer 1


If you can create a script (on the Puppet master) that will print the name (likely through calls to the AWS CLI), you can use the generate function to use the name in your Puppet manifests and templates.

You can add this call right in your site.pp file.

$rds_internal_name = generate('/usr/local/sbin/get-rds-internal-name')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .