title: Take input from CloudFormation parameter and pass it to script being downloaded from S3
body: <p>While creating along my AWS CloudFormation template I hit the 16KB limitation of user data.... and then I found out I can put the script in S3 (with all my user data) and copy that file over as part of user data and run that script... but my question is how can I take the parameters that I am passing into CloudFormation like below and pass that into the file/script/userdata that I download from S3 that I will run? So how can I pass the parameters from CloudFormation into <code>/root/usr.sh</code> script?</p>
  
  <p>Here is my user data:</p>
  
  <pre><code>"UserData": {
            "Fn::Base64": {
              "Fn::Join": [
                "",
                [
                  "#!/bin/bash -x\n\n",
                  "yum -y install tcsh lvm2 sysstat\n\n\n",
                  "# AWS CLI download and Installation\n",
                  "curl \"https://s3.amazonaws.com/aws-cli/awscli-bundle.zip\" -o \"/usr/awscli-bundle.zip\"\n",
                  "unzip /usr/awscli-bundle.zip -d /usr/awscmdline/\n",
                  "/usr/awscmdline/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws\n",
                  "/usr/local/aws/bin/aws configure set region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  "\n",
                  "/usr/local/bin/aws s3 cp s3://test123/usr.sh /root/usr.sh \n",
                  "chmod 744 /root/usr.sh \n",
                  "/root/usr.sh"
                ]
              ]
            }
          }
  </code></pre>
  
  <p>and here are the sample parameters:</p>
  
  <pre><code>"Parameters": {
      "SelectInstanceType": {
        "Description": "EC2 instance type",
        "Type": "String",
        "Default": "r3.8xlarge",
        "AllowedValues": [
          "r3.large",
          "r3.xlarge",
          "r3.2xlarge",
          "r3.4xlarge",
          "r3.8xlarge",
          "c4.large",
          "c4.xlarge",
          "c4.2xlarge",
          "c4.4xlarge",
          "c4.8xlarge"
        ],
        "ConstraintDescription": "Must be a valid EC2 instance type."
      },
      "Keyname": {
        "Description": "Keypair to use to launch the instance",
        "Type": "AWS::EC2::KeyPair::KeyName"
      },
      "IPAddress": {
        "Description": "Private IP",
        "Type": "String",
        "Default": "10.10.10.X"
      },
  </code></pre>