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