Search code examples
windowsamazon-web-servicesaws-cloudformation

Where is UserData script placed in a Windows EC2 instance?


Is the UserData part stored anywhere on a Windows EC2 machine? I need to examine it to see that input variables are correct.

On Ubuntu, it's supposed to be stored at /var/lib/cloud/instances/[instance-id]/user-data.txt according to this link.

The user data section in CloudFormation looks like this:

"UserData"         : {
    "Fn::Base64" : {
        "Fn::Join" : [
            "",
            [
                "<script>\n",
                "seedtool.exe ", { "Fn::GetAtt" : [ "DatabaseCluster" , "Endpoint.Address" ] }, "\n",
                "</script>\n"
            ]
        ]
    }
},

I need to see the user-data.txt so I can see what { "Fn::GetAtt" : [ "DatabaseCluster" , "Endpoint.Address" ] } resolves to.


Solution

  • User Data can be fetched from instance metadata, e.g. with Invoke-RestMethod -uri http://169.254.169.254/latest/user-data, for more details see http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-instance-metadata.html#instancedata-user-data-retrieval