Skip to content

Commit 54f21ce

Browse files
committed
Use session v2 API
1 parent 8060b46 commit 54f21ce

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

exp/controllers/rosaroleconfig_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"net/url"
2525
"strings"
2626

27-
"github.com/aws/aws-sdk-go/service/iam"
27+
iamv2 "github.com/aws/aws-sdk-go-v2/service/iam"
2828
"github.com/go-logr/logr"
2929
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
3030
accountroles "github.com/openshift/rosa/cmd/create/accountroles"
@@ -309,7 +309,7 @@ func (r *ROSARoleConfigReconciler) reconcileOIDCConfig(roleConfig *expinfrav1.RO
309309
}
310310
// Try to get OIDC UUID from some operator role policy document.
311311
roleName := fmt.Sprintf("%s-openshift-ingress-operator-cloud-credentials", roleConfig.Spec.OperatorRoleConfig.Prefix)
312-
roleDetails, err := scope.IAMClient().GetRole(&iam.GetRoleInput{
312+
roleDetails, err := scope.IAMClient().GetRole(context.TODO(), &iamv2.GetRoleInput{
313313
RoleName: &roleName,
314314
})
315315
if err != nil {
@@ -627,7 +627,7 @@ func (r ROSARoleConfigReconciler) operatorRolesReady(operatorRolesRef *v1beta2.A
627627
}
628628

629629
// GetOIDCIDFromOperatorRole extracts the OIDC UUID from the operator role policy document.
630-
func (r *ROSARoleConfigReconciler) GetOIDCIDFromOperatorRole(scope *scope.RosaRoleConfigScope, roleDetails *iam.GetRoleOutput) (string, error) {
630+
func (r *ROSARoleConfigReconciler) GetOIDCIDFromOperatorRole(scope *scope.RosaRoleConfigScope, roleDetails *iamv2.GetRoleOutput) (string, error) {
631631
decodedString, err := url.QueryUnescape(*roleDetails.Role.AssumeRolePolicyDocument)
632632
if err != nil {
633633
return "", err

pkg/cloud/scope/rosaroleconfig.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ package scope
1919
import (
2020
"context"
2121

22-
awsclient "github.com/aws/aws-sdk-go/aws/client"
23-
"github.com/aws/aws-sdk-go/service/iam"
22+
awsv2 "github.com/aws/aws-sdk-go-v2/aws"
23+
iamv2 "github.com/aws/aws-sdk-go-v2/service/iam"
2424
"github.com/pkg/errors"
2525
corev1 "k8s.io/api/core/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -52,8 +52,8 @@ type RosaRoleConfigScope struct {
5252
patchHelper *patch.Helper
5353
RosaRoleConfig *expinfrav1.ROSARoleConfig
5454
serviceLimiters throttle.ServiceLimiters
55-
session awsclient.ConfigProvider
56-
iamClient *iam.IAM
55+
session awsv2.Config
56+
iamClient *iamv2.Client
5757
}
5858

5959
// NewRosaRoleConfigScope creates a new RosaRoleConfigScope from the supplied parameters.
@@ -71,21 +71,21 @@ func NewRosaRoleConfigScope(params RosaRoleConfigScopeParams) (*RosaRoleConfigSc
7171
RosaRoleConfig: params.RosaRoleConfig,
7272
}
7373

74-
session, serviceLimiters, err := sessionForClusterWithRegion(params.Client, RosaRoleConfigScope, "", params.Endpoints, params.Logger)
74+
sessionv2, serviceLimitersv2, err := sessionForClusterWithRegionV2(params.Client, RosaRoleConfigScope, "", params.Endpoints, params.Logger)
7575
if err != nil {
76-
return nil, errors.Errorf("failed to create aws session: %v", err)
76+
return nil, errors.Errorf("failed to create aws V2 session: %v", err)
7777
}
7878

79-
iamClient := iam.New(session)
79+
iamClient := iamv2.NewFromConfig(*sessionv2)
8080

8181
patchHelper, err := patch.NewHelper(params.RosaRoleConfig, params.Client)
8282
if err != nil {
8383
return nil, errors.Wrap(err, "failed to init patch helper")
8484
}
8585

8686
RosaRoleConfigScope.patchHelper = patchHelper
87-
RosaRoleConfigScope.session = session
88-
RosaRoleConfigScope.serviceLimiters = serviceLimiters
87+
RosaRoleConfigScope.session = *sessionv2
88+
RosaRoleConfigScope.serviceLimiters = serviceLimitersv2
8989
RosaRoleConfigScope.iamClient = iamClient
9090

9191
return RosaRoleConfigScope, nil
@@ -96,8 +96,8 @@ func (s *RosaRoleConfigScope) IdentityRef() *infrav1.AWSIdentityReference {
9696
return s.RosaRoleConfig.Spec.IdentityRef
9797
}
9898

99-
// Session returns the AWS SDK session (used for creating clients).
100-
func (s *RosaRoleConfigScope) Session() awsclient.ConfigProvider {
99+
// Session returns the AWS SDK V2 session. Used for creating clients.
100+
func (s *RosaRoleConfigScope) Session() awsv2.Config {
101101
return s.session
102102
}
103103

@@ -165,6 +165,6 @@ func (s *RosaRoleConfigScope) CredentialsSecret() *corev1.Secret {
165165
}
166166

167167
// IAMClient returns the IAM client.
168-
func (s *RosaRoleConfigScope) IAMClient() *iam.IAM {
168+
func (s *RosaRoleConfigScope) IAMClient() *iamv2.Client {
169169
return s.iamClient
170170
}

0 commit comments

Comments
 (0)