diff --git a/cmd/create/cluster/cmd.go b/cmd/create/cluster/cmd.go index 8d781189e8..3738670c54 100644 --- a/cmd/create/cluster/cmd.go +++ b/cmd/create/cluster/cmd.go @@ -1187,7 +1187,9 @@ func run(cmd *cobra.Command, _ []string) { externalAuthProvidersEnabled := args.externalAuthProvidersEnabled if externalAuthProvidersEnabled { if !isHostedCP { - r.Reporter.Errorf("External authentication configuration is only supported for a Hosted Control Plane cluster.") + r.Reporter.Errorf( + "External authentication configuration is only supported for a Hosted Control Plane cluster.", + ) os.Exit(1) } } @@ -2372,7 +2374,7 @@ func run(cmd *cobra.Command, _ []string) { // Compute node instance type: computeMachineType := args.computeMachineType computeMachineTypeList, err := r.OCMClient.GetAvailableMachineTypesInRegion(region, availabilityZones, roleARN, - awsClient) + awsClient, externalID) if err != nil { r.Reporter.Errorf(fmt.Sprintf("%s", err)) os.Exit(1) diff --git a/cmd/list/instancetypes/cmd.go b/cmd/list/instancetypes/cmd.go index d876ef2356..235d317439 100644 --- a/cmd/list/instancetypes/cmd.go +++ b/cmd/list/instancetypes/cmd.go @@ -142,7 +142,7 @@ func runWithRuntime(r *rosa.Runtime, cmd *cobra.Command) error { } availableMachineTypes, err := r.OCMClient.GetAvailableMachineTypesInRegion(arguments.GetRegion(), - availabilityZones, roleArn, r.AWSClient) + availabilityZones, roleArn, r.AWSClient, args.externalId) if err != nil { return fmt.Errorf("Failed to fetch instance types: %v", err) } diff --git a/pkg/machinepool/machinepool.go b/pkg/machinepool/machinepool.go index 4af80c6032..2f6824a335 100644 --- a/pkg/machinepool/machinepool.go +++ b/pkg/machinepool/machinepool.go @@ -340,6 +340,7 @@ func (m *machinePool) AddMachinePool(cmd *cobra.Command, clusterKey string, clus availabilityZonesFilter, cluster.AWS().STS().RoleARN(), r.AWSClient, + cluster.AWS().STS().ExternalID(), ) if err != nil { return fmt.Errorf(fmt.Sprintf("%s", err)) @@ -811,7 +812,7 @@ func (m *machinePool) AddNodePool(cmd *cobra.Command, clusterKey string, cluster } instanceTypeList, err := r.OCMClient.GetAvailableMachineTypesInRegion(cluster.Region().ID(), - availabilityZonesFilter, cluster.AWS().STS().RoleARN(), r.AWSClient) + availabilityZonesFilter, cluster.AWS().STS().RoleARN(), r.AWSClient, cluster.AWS().STS().ExternalID()) if err != nil { return fmt.Errorf(fmt.Sprintf("%s", err)) } diff --git a/pkg/ocm/machines.go b/pkg/ocm/machines.go index b445eedec5..ead0612165 100644 --- a/pkg/ocm/machines.go +++ b/pkg/ocm/machines.go @@ -120,8 +120,8 @@ func (mt MachineType) HasQuota(multiAZ bool) bool { // The function triggers the 'api/clusters_mgmt/v1/aws_inquiries/machine_types' // and passes a role ARN for STS clusters or access keys for non-STS clusters. func (c *Client) GetAvailableMachineTypesInRegion(region string, availabilityZones []string, roleARN string, - awsClient aws.Client) (MachineTypeList, error) { - cloudProviderDataBuilder, err := c.createCloudProviderDataBuilder(roleARN, awsClient, "") + awsClient aws.Client, externalId string) (MachineTypeList, error) { + cloudProviderDataBuilder, err := c.createCloudProviderDataBuilder(roleARN, awsClient, externalId) if err != nil { return MachineTypeList{}, err } @@ -234,7 +234,8 @@ func (mtl *MachineTypeList) UpdateAvailableQuota(quotaCosts *amsv1.QuotaCostList } quotaCosts.Each(func(quotaCost *amsv1.QuotaCost) bool { for _, relatedResource := range quotaCost.RelatedResources() { - if machineType.MachineType.GenericName() == relatedResource.ResourceName() && isCompatible(relatedResource) { + if machineType.MachineType.GenericName() == relatedResource.ResourceName() && + isCompatible(relatedResource) { availableQuota := (quotaCost.Allowed() - quotaCost.Consumed()) / relatedResource.Cost() machineType.Available = availableQuota > 1 machineType.availableQuota = availableQuota