diff --git a/pkg/actuators/machine/instances.go b/pkg/actuators/machine/instances.go index fe55a58eee..c5ecabf623 100644 --- a/pkg/actuators/machine/instances.go +++ b/pkg/actuators/machine/instances.go @@ -342,7 +342,7 @@ func launchInstance(machine *machinev1.Machine, machineProviderConfig *awsprovid } } - instanceTenancy := machineProviderConfig.Tenancy + instanceTenancy := machineProviderConfig.Placement.Tenancy switch instanceTenancy { case "": @@ -351,7 +351,7 @@ func launchInstance(machine *machinev1.Machine, machineProviderConfig *awsprovid if placement == nil { placement = &ec2.Placement{} } - tenancy := string(machineProviderConfig.Tenancy) + tenancy := string(instanceTenancy) placement.Tenancy = &tenancy default: return nil, mapierrors.CreateMachine("invalid instance tenancy: %s. Allowed options are: %s,%s,%s", diff --git a/pkg/actuators/machine/stubs.go b/pkg/actuators/machine/stubs.go index fad8ac8878..927f8eb851 100644 --- a/pkg/actuators/machine/stubs.go +++ b/pkg/actuators/machine/stubs.go @@ -218,13 +218,13 @@ func stubPCAMI(ami awsproviderv1.AWSResourceReference) *awsproviderv1.AWSMachine func stubDedicatedInstanceTenancy() *awsproviderv1.AWSMachineProviderConfig { pc := stubProviderConfig() - pc.Tenancy = awsproviderv1.DedicatedTenancy + pc.Placement.Tenancy = awsproviderv1.DedicatedTenancy return pc } func stubInvalidInstanceTenancy() *awsproviderv1.AWSMachineProviderConfig { pc := stubProviderConfig() - pc.Tenancy = "invalid" + pc.Placement.Tenancy = "invalid" return pc } diff --git a/pkg/apis/awsprovider/v1beta1/awsproviderconfig_types.go b/pkg/apis/awsprovider/v1beta1/awsproviderconfig_types.go index 33c73845e0..6e377f6116 100644 --- a/pkg/apis/awsprovider/v1beta1/awsproviderconfig_types.go +++ b/pkg/apis/awsprovider/v1beta1/awsproviderconfig_types.go @@ -88,10 +88,6 @@ type AWSMachineProviderConfig struct { // SpotMarketOptions allows users to configure instances to be run using AWS Spot instances. SpotMarketOptions *SpotMarketOptions `json:"spotMarketOptions,omitempty"` - - // Tenancy indicates if instance should run on shared or single-tenant hardware. There are - // supported 3 options: default, dedicated and host. - Tenancy InstanceTenancy `json:"tenancy,omitempty"` } // BlockDeviceMappingSpec describes a block device mapping @@ -200,6 +196,10 @@ type Placement struct { // AvailabilityZone is the availability zone of the instance AvailabilityZone string `json:"availabilityZone,omitempty"` + + // Tenancy indicates if instance should run on shared or single-tenant hardware. There are + // supported 3 options: default, dedicated and host. + Tenancy InstanceTenancy `json:"tenancy,omitempty"` } // Filter is a filter used to identify an AWS resource