aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Updating CoreOS cloud config via user-data fails when trying to update with file

Open austenLacy opened this issue 10 years ago • 5 comments

Running the following command:

$ aws ec2 --profile myprof modify-instance-attribute --instance-id=i-XXXXXX --user-data file://some-cloud-config.yaml

throws the following error:

Error parsing parameter '--user-data': Expected: '=', received: '#' for input:
#cloud-config
^

The cloud config works perfectly when doing aws ec2 run-instances --user-data file://some-cloud-config.yaml ...

austenLacy avatar May 31 '16 15:05 austenLacy

This is a unfortunate but the API for modify-instance-attribute is different than run-instances, but for --user-data for modify-instance-attribute as shown in the docs requires a Value key. So something like:

--user-data Value='my yaml contents'

Probably, the larger issue is that for nested parameters like this you cannot use file://. Instead you will have to cat the contents of the file into the command. So something like this:

$ aws ec2 modify-instance-attribute --instance-id=i-XXXXXX --user-data Value="$(cat some-cloud-config.yaml)"

There is not really much we can do to make this consistent because this was just how the EC2 API was modeled and the CLI more or less directly reflects it, but I hopes this helps.

kyleknap avatar Jun 03 '16 00:06 kyleknap

I think that's a valid solution. I'll try it out soon. I think it could be worthwhile to add that use case/example in the docs since the use of --user-data would imply it works similarly to other commands (i.e. run-instances)

austenLacy avatar Jun 03 '16 01:06 austenLacy

Sounds good. We can get an example added for this.

kyleknap avatar Jun 03 '16 17:06 kyleknap

@kyleknap yes, please! and thanks for offering the hint.

danvaida avatar Dec 12 '16 17:12 danvaida

Greetings! It looks like this issue hasn’t been active in longer than one year. We encourage you to check if this is still an issue in the latest release. Because it has been longer than one year since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment to prevent automatic closure, or if the issue is already closed, please feel free to reopen it.

github-actions[bot] avatar Jul 14 '21 23:07 github-actions[bot]