Apply this ISCM configuration into a launchable resource, such as
        an EC2 instance or an AutoScalingGroup LaunchConfig.

def apply_to(self, launchable):
        """
        Apply this ISCM configuration into a launchable resource, such as
        an EC2 instance or an AutoScalingGroup LaunchConfig.
        """
        # Update user data
        if launchable.get_property("UserData") is not None:
            raise NotImplementedError("It's not yet supported to append SCM to existing userdata")
        user_data = {
            "Fn::Base64" : {
                "Fn::Join" : ["", [
                    "\n".join([
                        r'#!/bin/bash',
                        r'FATAL() { code=$1; shift; echo "[FATAL] $*" >&2; exit $code; }',
                        r'ERROR() { echo "[ERROR] $*" >&2 ; }',
                        r'WARN()  { echo "[WARNING] $*" >&2 ; }',
                        r'INFO()  { echo "[INFO] $*" >&2 ; }', "",
                    ])
                ] + (self.wc_handle is not None and [
                    cfnjoin("",
                        r'ISCM_WCHANDLE_URL="', self.wc_handle, '"\n'
                    )
                ] or []) + [
                    "\n".join([
                        r'{',
                        r'INFO "CloudCast ISCM booting on $(date)"',
                        "\n\n"
                    ])
                ] + self.userdata_elems + [
                    "\n".join([ "",
                        r'iscm_result=$?',
                        r'[ -n "$ISCM_WCHANDLE_URL" ] && [ -n "$(which cfn-signal)" ] && cfn-signal -e $iscm_result $ISCM_WCHANDLE_URL',
                        '\nINFO "CloudCast ISCM successfully completed on $(date)"',
                        '} 2>&1 | tee -a /iscm.log\n'
                    ])
                ]
            ]} 
        }
        launchable.add_property("UserData", user_data)

        # Set meta data keys
        for k in self.metadata:
            if launchable.get_metadata_key(k) is not None:
                raise NotImplementedError("It's not yet supported to append to existing metadata keys")
            launchable.add_metadata_key(k, self.metadata[k])