title: Unable to set environment variable for aws lambda function executed as AWS::CloudFormation::CustomResource
body: <p>I am trying to set the environment variable which takes it's value at runtime through my CloudFormation template json for CustomResource. So that later it executes a python lambda and I can read the environment variable in the lambda and process some data.</p>
  
  <p>I want my python lambda to be able to read this variable inside os.environ</p>
  
  <p>Following is my Cloudformation for CustomResource</p>
  
  <pre><code>"TriggerRedshiftSetupLambda": {
        "Type": "AWS::CloudFormation::CustomResource",
        "Version": 1.0,
        "Properties": {
         "Environment": {
            "Variables": {
              "AHost": {
                  "Fn::GetAtt" : [ "A", "Endpoint.Address" ]
              },
              "APort": {
                  "Fn::GetAtt" : [ "A", "Endpoint.Port" ]
              }
           }
          },
          "ServiceToken": {
            "Fn::GetAtt" : [ "ASetupLambda", "Arn" ]
          }
        }
      }
  </code></pre>
  
  <p>Here is my lambda code using the variable</p>
  
  <pre><code>def lambda_handler(event, context):
      print(os.environ)
      print(os.environ['AHost'])
  </code></pre>
  
  <p>The 1st print statement prints the entire environment variables list but doesn't have any key / value pair for 'AHost'</p>
  
  <p>Am I doing something wrong? How to initialize environment variables through customresource for lambda correctly?</p>