Closed brickZA closed 3 weeks ago
Thanks for reaching out. The ec2 modify-instance-attribute command (and underlying API) require --value
to be a string:
If you base64 encode your string then this will work:
aws ec2 modify-instance-attribute --instance-id i-072f97fe523412345 --attribute userData --value "$(cat userdata.sh.gz | base64)"
And to verify you can run:
aws ec2 describe-instance-attribute --instance-id i-072f97fe523412345 --attribute userData
Which returns:
{
"InstanceId": "i-072f97fe523412345",
"UserData": {
"Value": "H4sICC7eYWYAA3VzZXJkYXRhLnNoAFNW1E/KzNNPSizO4EpNzshXUArJyCxWAKJEheLE3IKcVIXS4tQi3ZTEEqBAclFmQYmeEgCtxpQgNQAAAA=="
}
}
And then you can decode it:
echo "JVNIQkFTSENPTU1BTkQKZWNobyAiVGhpcyBpcyBhIHNhbXBsZSB1c2VyLWRhdGEgc2NyaXB0LiIK" | base64 --decode
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.
Describe the bug
When trying to modify an ec2 instance's user-data with binary data using the
fileb://
prefix parameter validation fails.E.g. calling with the
file://
prefix results in a seeming helpful error message:but following the suggestion does not work.
Expected Behavior
The binary file should be properly interpreted and set as the
user-data
for the ec2 instance.Current Behavior
Reproduction Steps
See current behaviour.
Possible Solution
No response
Additional Information/Context
No response
CLI version used
aws-cli/2.16.1 Python/3.11.8 Linux/6.5.0-35-lowlatency exe/x86_64.ubuntu.22
Environment details (OS name and version, etc.)
Ubuntu 22.04