Rancher CLI Host creation on AWS gives random ec2 name

Hi I used the following command in the CLI:

rancher hosts create --driver amazonec2 --amazonec2-region ap-southeast-2 --amazonec2-access-key xxxxxxxxxxx --amazonec2-secret-key xxxxxxxxxxxxxx --amazonec2-zone a --amazonec2-vpc-id vpc-14a77f70 --amazonec2-subnet-id subnet-c7bc33b1 --amazonec2-security-group rancher-stack-InstanceSecurityGroup-NBXTQ4RG4UJM --name host-01

It created the ec2 instance but it didn’t give the instance the name that I wanted which was ‘host-01’. Instead it called it ‘drunk-chandrasekhar’. In the Rancher Hosts section it is called ‘host-01’ but not in the AWS instances dashboard. I couldn’t see another option other than --name. How can I amend my command to give the new ec2 instance the name that I want?

Hi,

I know this is old, but AWS Names instances based on Tags.

Add the following to your rancher cli command

 --amazonec2-tags Name,${HOST_NAME}