I deploy some VM's instances in my cloud infrastructure with bash script:
#!/bin/bash
instance_name="vm"
# create instance
yc compute instance create \
--name $instance_name \
--hostname reddit-app \
--memory=2 \
...
I need to add timestamp to instance's name in format vm-DD-MM_YYYY-H-M-S
.
For debug I tried to set value instance_name=$(date +%d-%m-%Y_%H-%M-%S)
but got the error:
ERROR: rpc error: code = InvalidArgument desc = Request validation error: Name: invalid resource name
Any help would be appreciated.
The Yandex Cloud
documentation says:
"The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character can't be a hyphen. The maximum length of the name is 63 characters".
I changed my script following the recommendations and it works now:
#!/bin/bash
instance_name="vm-$(date +%d-%m-%Y-%H-%M-%S)"
# create instance
yc compute instance create \
--name $instance_name \
--hostname reddit-app \
--memory=2 \
...