X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3a9428dd1db2fd393dd90cd3ffc744c0bf45fe28..03c01a2340c42fbd9098f248c609f611f361c3a6:/lib/cloud/ec2/ec2.go?ds=sidebyside diff --git a/lib/cloud/ec2/ec2.go b/lib/cloud/ec2/ec2.go index 81e1f8b00e..e2cf5e0f1c 100644 --- a/lib/cloud/ec2/ec2.go +++ b/lib/cloud/ec2/ec2.go @@ -149,11 +149,6 @@ func (instanceSet *ec2InstanceSet) Create( initCommand cloud.InitCommand, publicKey ssh.PublicKey) (cloud.Instance, error) { - keyname, err := instanceSet.getKeyName(publicKey) - if err != nil { - return nil, err - } - ec2tags := []*ec2.Tag{} for k, v := range newTags { ec2tags = append(ec2tags, &ec2.Tag{ @@ -172,7 +167,6 @@ func (instanceSet *ec2InstanceSet) Create( InstanceType: &instanceType.ProviderType, MaxCount: aws.Int64(1), MinCount: aws.Int64(1), - KeyName: &keyname, NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{ { @@ -192,6 +186,14 @@ func (instanceSet *ec2InstanceSet) Create( UserData: aws.String(base64.StdEncoding.EncodeToString([]byte("#!/bin/sh\n" + initCommand + "\n"))), } + if publicKey != nil { + keyname, err := instanceSet.getKeyName(publicKey) + if err != nil { + return nil, err + } + rii.KeyName = &keyname + } + if instanceType.AddedScratch > 0 { rii.BlockDeviceMappings = []*ec2.BlockDeviceMapping{{ DeviceName: aws.String("/dev/xvdt"),