diff --git a/spinifex/handlers/ec2/instance/service_impl.go b/spinifex/handlers/ec2/instance/service_impl.go index ce609cc16..4ad7e0ea2 100644 --- a/spinifex/handlers/ec2/instance/service_impl.go +++ b/spinifex/handlers/ec2/instance/service_impl.go @@ -177,7 +177,7 @@ func UnservedBlockDeviceMappings(mappings []*ec2.BlockDeviceMapping) []string { func parseVolumeParams(input *ec2.RunInstancesInput) volumeParams { p := volumeParams{ size: 4 * 1024 * 1024 * 1024, // 4GB default - deviceName: "/dev/vda", + deviceName: ebsmetadata.RootDeviceName, deleteOnTermination: true, // matches AWS RunInstances behavior } diff --git a/spinifex/handlers/ec2/instance/service_impl_test.go b/spinifex/handlers/ec2/instance/service_impl_test.go index 84e934291..a845ce5b4 100644 --- a/spinifex/handlers/ec2/instance/service_impl_test.go +++ b/spinifex/handlers/ec2/instance/service_impl_test.go @@ -376,7 +376,7 @@ func TestParseVolumeParams_Defaults(t *testing.T) { p := parseVolumeParams(input) assert.Equal(t, 4*1024*1024*1024, p.size, "default size should be 4GB") - assert.Equal(t, "/dev/vda", p.deviceName, "default device should be /dev/vda") + assert.Equal(t, ebsmetadata.RootDeviceName, p.deviceName, "default device should be the name the AMI declares") assert.True(t, p.deleteOnTermination, "deleteOnTermination should default to true") assert.Empty(t, p.volumeType) assert.Zero(t, p.iops) @@ -454,7 +454,7 @@ func TestParseVolumeParams_PartialEbs(t *testing.T) { p := parseVolumeParams(input) assert.Equal(t, 8*1024*1024*1024, p.size) - assert.Equal(t, "/dev/vda", p.deviceName, "device should stay at default") + assert.Equal(t, ebsmetadata.RootDeviceName, p.deviceName, "device should stay at default") assert.Empty(t, p.volumeType, "volumeType should stay empty") assert.Zero(t, p.iops, "iops should stay zero") assert.True(t, p.deleteOnTermination, "deleteOnTermination should stay at default") diff --git a/spinifex/handlers/ecs/capacity.go b/spinifex/handlers/ecs/capacity.go index 124f6f6b7..b49048e44 100644 --- a/spinifex/handlers/ecs/capacity.go +++ b/spinifex/handlers/ecs/capacity.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mulgadc/spinifex/spinifex/awserrors" + "github.com/mulgadc/spinifex/spinifex/ebsmetadata" "github.com/mulgadc/spinifex/spinifex/instancetypes" "github.com/mulgadc/spinifex/spinifex/tags" "github.com/mulgadc/spinifex/spinifex/utils" @@ -132,7 +133,7 @@ func (s *Service) ProvisionCapacity(ctx context.Context, input *ProvisionCapacit UserData: aws.String(userData), IamInstanceProfile: &ec2.IamInstanceProfileSpecification{Arn: aws.String(profileARN)}, BlockDeviceMappings: []*ec2.BlockDeviceMapping{{ - DeviceName: aws.String("/dev/vda"), + DeviceName: aws.String(ebsmetadata.RootDeviceName), Ebs: &ec2.EbsBlockDevice{VolumeSize: aws.Int64(diskSize)}, }}, TagSpecifications: []*ec2.TagSpecification{{ diff --git a/spinifex/handlers/eks/nodegroup.go b/spinifex/handlers/eks/nodegroup.go index 9b0033f34..9b83bc11e 100644 --- a/spinifex/handlers/eks/nodegroup.go +++ b/spinifex/handlers/eks/nodegroup.go @@ -23,6 +23,7 @@ import ( "github.com/mulgadc/bluebottle/pkg/auth" "github.com/mulgadc/spinifex/spinifex/arn" "github.com/mulgadc/spinifex/spinifex/awserrors" + "github.com/mulgadc/spinifex/spinifex/ebsmetadata" handlers_iam "github.com/mulgadc/spinifex/spinifex/handlers/iam" "github.com/mulgadc/spinifex/spinifex/instancetypes" "github.com/nats-io/nats.go/jetstream" @@ -664,7 +665,7 @@ func (s *EKSServiceImpl) launchOneWorker(ctx context.Context, rec *NodegroupReco } if rec.DiskSize > 0 { runInput.BlockDeviceMappings = []*ec2.BlockDeviceMapping{{ - DeviceName: aws.String("/dev/vda"), + DeviceName: aws.String(ebsmetadata.RootDeviceName), Ebs: &ec2.EbsBlockDevice{VolumeSize: aws.Int64(rec.DiskSize)}, }} }