Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Has anyone successful passed user data to the AWS CLI ?

I have tried various incantations of the following but it does not work.

Docs say string must be base64 encoded : http://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html

The instance logs never indicate the script is executed and chef is installed.

aws ec2 run-instances --image-id ami-a73264ce --count 1 --instance-type t1.micro       --key-name scrubbed --iam-instance-profile Arn=arn:aws:iam::scrubbed:instance-profile/scrubbed --user-data $(base64 chef_user_data.sh --wrap=0)

chef_user_data.sh

#!/bin/bash
curl -L https://www.opscode.com/chef/install.sh | sudo bash
share|improve this question

2 Answers 2

up vote 1 down vote accepted

The documentation is inconsistent between the : aws website, the git repo for the tool and the output of the tool itself.

It seems the most up to date info is in the repo pages : https://github.com/aws/aws-cli

The answer is the use something like : --user-data file://chef_user_data.sh

share|improve this answer

Yes we have. The parameter works as defined, BUT the problem is that the ec2 treats userdata as an opaque data type - it passes it along as is, with no concrete representation of what it really is - that is left to the consuming app process on the instance. The command line nature of the CLI requires this encoding, but then the receiving process is now obligated to decode it. And Chef does not. Nor does CloudINIT.net. You can confirm this by checking the instance meta data at

    http://169.254.169.254/latest/user-data

Seems like the CLI should encode the base64 userdata payload.

EDIT: Turns out the documentation is bad, the -user-data param actually accepts a file param, and does the encoding. --user-data file:///path/to/the/file. See https://github.com/aws/aws-cli/issues/366

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.