Creating EC2 host via API POST gives "No Machine Name Specified"

Hi, I am trying to create Rancher EC2 hosts via the API but am getting the message “No Machine Name Specified

I’m unsure what this relates to as I can’t see any corresponding entry option. My POST request looks like the following (obv with valid keys, vpc/subnet IDs) :

	"amazonec2Config": {
		"ami": "ami-c62170b5",
		"blockDurationMinutes": "0",
		"deviceName": "/dev/sda1",
		"insecureTransport": false,
                "instanceType": "t2.micro",
		"monitoring": false,
		"privateAddressOnly": false,
		"region": "eu-west-1",
		"requestSpotInstance": false,
		"rootSize": "8",
		"secretKey": "1234567890abcdefghijklmnopgrstuvwxyz",
		"securityGroup": [
		"sshUser": "rancher",
		"subnetId": "subnet-abcd1234",
		"tags": "rancher-host",
		"useEbsOptimizedInstance": false,
		"usePrivateAddress": false,
		"volumeType": "gp2",
		"vpcId": "vpc-abcd1234",
		"zone": "a"
	"description": "rancher-host",
	"hostname": "rancher-host",
	"name": "rancher-host"

I am using -


Any pointers much appreciated.

Many thanks.

To update, we have got past the error by using v2-beta of the API as oppose to v1 (Ok yes, we maybe should have gone for v2 from the start), however for info we aren’t (as yet) using API keys, but rather relying on EC2 security group IP access lockdown. Perhaps not ideal but for our purposes at this stage of development it lets us progress with a workflow.

As such (with no API creds) the short version as advised in the API docs for v2 didn’t work (hence why we tried v1)…


…this returned 405 Method not allowed

However the longer string worked fine -


That said, I think the 405 Method not allowed might still an issue and that we should be able to create hosts without API creds using the shorter v2-beta option (Perhaps, perhaps not, happy to be corrected and/or advised as to why/why not).

The original issue is apparently a bug in the v1 backwards compatibility, but in v1 you shouldn’t be able to create a host like that at all, you create a machine and the host is indirectly created one is registered. Anyway the v2 one is simpler.

When you have access control off, you are implicitly authenticated as the admin account. Hosts must be owned by a particular project/environment, but by using the root (/v2-beta/hosts) you are trying to create one owned by a user. The only times you don’t need to specify the project ID are when creating resources not owned by a project (mostly just users and projects themselves), or when using an API key tied to a particular project (instead of a user).

Thank you for the explanation Vincent, the extra insight is most useful.

We are getting there slowly :grinning::+1: