cryptobiu/MATRIX

Naming of Key Pairs

Closed this issue · 1 comments

Hi,

I have used the Create Key pair(s) option from the Deploy menu. This resulted in the creation of a private key Matrixuseast1-1 in ~/Keys where the filename has suffix -1.

key_pair = client.create_key_pair(KeyName='Matrix%s-%s'
% (regions[regions_idx].replace('-', '')[:-1], key_idx))

During deployment, the Matrix client tries to use the key name from regions.json where this suffix is omitted (it is just Matrixuseast1).

client.request_spot_instances(
DryRun=False,
SpotPrice=price_bids,
InstanceCount=number_of_instances_to_deploy,
ValidUntil=new_date,
LaunchSpecification=
{
'ImageId': global_config[regions[idx][:-1]]["ami"],
'KeyName': global_config[regions[idx][:-1]]["key"],
'SecurityGroups': [global_config[regions[idx][:-1]]["securityGroup"]],
'InstanceType': machine_type,
'Placement':
{
'AvailabilityZone': regions[idx],
},
}
)

Choose deployment task
1. Deploy Instance(s)
2. Create Key pair(s)
3. Create security group(s)
4. Get instances network data
5. Terminate machines
6. Change machines types
7. Start instances 
8. Stop instances
Your choice:1
Current date : 
2018-09-11 14:23:54.714932
Deploying instances :
region : us-east-1b
number of instances : 3
ami_id : ami-08c9a677
instance_type : c4.large
valid until : 2018-09-11 20:23:54.714932
THE KEY PAIR 'MATRIXUSEAST1' DOES NOT EXIST
Waiting for the images to be deployed..

I can change the entry of the regions.json, but I am not sure what happens when there are multiple regions involved.

Hi,

At your config file, you defined your requested regions:

"regions":
{
"region_0":"us-east-1b"
},

The b at the end specify the placement group inside the region.
Since the regions.json file is common to all the placement groups inside a region, the code snippet omits the placemant group specifier and not the suffix of the key name.

Hence you should change the regions.json file according to your key file name.