title: Reference resource in CloudFormation template in inline code property of a Lambda function
body: <p>I have a <code>CloudFormation</code> template that has a <code>Lambda</code> function resource that is triggered by a CloudWatch event when a new <code>AMI</code> is registered. In the Lambda resource block, I pass my inline code in the <code>Code</code> property. The function triggers an <code>SSM</code> automation document execution if the <code>AMI</code> id is the desired id parsed in the return event. For the sake of the question, let's call this resource <code>My Doc</code> in the template. So, my question is, in my template how would I reference the Automation Document resource in my inlide code in the <code>Code</code> property of the <code>Lambda</code> resource? I have pasted a code sample below to help illustrate this.</p>
  
  <p>Resource blocks from template:</p>
  
  <pre><code>"MyDoc": {
      {
        "Type" : "AWS::SSM::Document",
        "Properties" : {
          "Content" : JSON object,
          "DocumentType" : Automation,
          "Tags" : [ Resource Tag, ... ]
        }
  }
  
  "MyLambdaFunction": {
        "Type": "AWS::Lambda::Function",
        "Properties": {
                    "Role": {
                        "Fn::GetAtt": [
                            "SomeRole",
                            "Arn"
                        ]
                    },
                    "Code": {
                        "ZipFile": {
                            "Fn::Join": [
                                "\n",
                                [
                                    "import json",
                                    "import boto3",
                                    "def lambda_handler(event, context):",
                                    "    ssm = boto3.client('ssm')",
                                    "    amiId = event['AMI-ID']",
  
                                    "    if 'base_ami in amiId:",
                                    "         ssm.start_automation_execution(DocumentName=THIS IS WHERE I NEED TO REFERENCE THE DOCUMENT RESOURCE)",
                                    "    else:",
                                    "        print("Not the base AMI id.")"
                                ]
                            ]
                        }
                    },
                    "Runtime": "python3.6",
                    "Timeout": 300,
                    "Handler": "index.lambda_handler",
                    "MemorySize": 512
                }
            },
            ...
  </code></pre>