I know this thread is old but I have just been investigating this. First the disclaimer: I am pretty familiar with Python but very new to CouldFormation and Troposphere so I may have missed something very important regarding "Ref".
My ad-hoc approach to this was to add a few lines to troposphere/__init__.py that extract the .title attribute if it exists and is a string.
--- a/troposphere/__init__.py
+++ b/troposphere/__init__.py
@@ -92,6 +92,11 @@ class BaseAWSObject(object):
# Check the type of the object and compare against what we were
# expecting.
expected_type = self.props[name][0]
+
+ # Auto-deduce Ref
+ #
+ if hasattr(value, 'title') and isinstance(value.title, str):
+ return self.properties.__setitem__(name, value.title)
# If the value is a AWSHelperFn we can't do much validation
# we'll have to leave that to Amazon. Maybe there's another way
As an example, line 32 in examples/EC2InstanceSample.py could be changed as shown below, skipping the Ref() encapsulation. The generated output would remain the same.
#KeyName=Ref(keyname_param),
KeyName=keyname_param,There should probably some more checks as in the get_data() method of the AWSHelperFn class.
Markus