@@ -41,11 +41,12 @@ var (
4141)
4242
4343const (
44- errUnsupportedCAPATenancy = "unable to convert tenancy, unknown value"
45- errUnsupportedCAPAMarketType = "unable to convert market type, unknown value"
46- errUnsupportedHTTPTokensState = "unable to convert httpTokens state, unknown value" //nolint:gosec // This is an error message, not a credential
47- defaultIdentityName = "default"
48- defaultCredentialsSecretName = "aws-cloud-credentials" //#nosec G101 -- False positive, not actually a credential.
44+ errUnsupportedCAPATenancy = "unable to convert tenancy, unknown value"
45+ errUnsupportedCAPAMarketType = "unable to convert market type, unknown value"
46+ errUnsupportedHTTPTokensState = "unable to convert httpTokens state, unknown value" //nolint:gosec // This is an error message, not a credential
47+ defaultIdentityName = "default"
48+ defaultCredentialsSecretName = "aws-cloud-credentials" //#nosec G101 -- False positive, not actually a credential.
49+ errUnsupportedHostAffinityType = "unable to convert hostAffinity, unknown value"
4950)
5051
5152// machineAndAWSMachineAndAWSCluster stores the details of a Cluster API Machine and AWSMachine and AWSCluster.
@@ -167,6 +168,25 @@ func (m machineAndAWSMachineAndAWSCluster) toProviderSpec() (*mapiv1beta1.AWSMac
167168 MarketType : mapiAWSMarketType ,
168169 }
169170
171+ // Dedicated host support
172+ if m .awsMachine .Spec .HostAffinity != nil {
173+ switch * m .awsMachine .Spec .HostAffinity {
174+ case "host" :
175+ mapaProviderConfig .HostPlacement = & mapiv1beta1.HostPlacement {
176+ Affinity : ptr .To (mapiv1beta1 .HostAffinityDedicatedHost ),
177+ DedicatedHost : & mapiv1beta1.DedicatedHost {
178+ ID : * m .awsMachine .Spec .HostID ,
179+ },
180+ }
181+ case "default" :
182+ mapaProviderConfig .HostPlacement = & mapiv1beta1.HostPlacement {
183+ Affinity : ptr .To (mapiv1beta1 .HostAffinityAnyAvailable ),
184+ }
185+ default :
186+ errors = append (errors , field .Invalid (fldPath .Child ("hostAffinity" ), m .awsMachine .Spec .HostAffinity , errUnsupportedHostAffinityType ))
187+ }
188+ }
189+
170190 secretRef , errs := handleAWSIdentityRef (fldPath .Child ("identityRef" ), m .awsCluster .Spec .IdentityRef )
171191
172192 if len (errs ) > 0 {
0 commit comments