Skip to content

Move NewSession to manager.go to allow endpoint-url to use EndpointResolver #896

@ryansteakley

Description

@ryansteakley

Is your feature request related to a problem?

  • Current implementation of endpointUrl configures the awscfg before the call to session.NewSession().
  • If you are using oidc, internally NewSession will call stsAssumeRoleWithWebIdentity or if you are using cross account the call to stsAssumeRole will also occur.
  • The issue lies in the fact that if one is using a custom endpoint for example to the sagemaker service, when stsAssumeRole is called it will throw a 404 as we can no longer reach that service.
  • This occurs because the awscfg.Endpoint has been set to the sagemaker endpoint so now we only allow traffic to sagemaker services. As a a result of this the current implementation of endpointUrl does not work when the user is using either crossAccount or OIDC roles.

Describe the solution you'd like

  • To use the endpointResolver function as provided by the aws go sdk. Here we can specify when the service == sagemaker.EndpointsID to use our custom sagemaker endpoint.

  • As a result we are only using this endpoint for sagemaker api calls and we still have access to the stsAssumeRole calls.

  • To allow for a better user experience instead of having them provide the service-id.EndpointsID we would move this to each resources Manager.go file to create the session and populate this check with the respective service-id and its respective EndpointsID.

  • To make this change the aws_resource_manager.go struct for an AWSResourceManager needs to accept endpointUrl as well as the gvk and the service controllers VersionInfo so that we can make the injectUserAgent call.

  • Then in the manager.go we will create the session and utilize the EndpointResolver func so that EndpointUrl can work when using OIDC and cross account.

  • If the community thinks this is a good solution, I will implement it and get it out for code review

Describe alternatives you've considered
A description of any alternative solutions or features you've considered.

  • Have tested all three of these alternatives and they work to resolve this issue however none of them seem to be the best way to resolve things.
  1. Make user manually find the endpointsID and pass it in as another variable to the config..... Trying to avoid this with the solution I described above

  2. Call session.NewSession() again after the initial call and grabbing the credentials from the returned session object and then calling session.NewSession() with those credentials so we don't have to call stsAssumeRole.

  3. Set awscfg.Endpoint at the end of newSession instead of at the beginning and Return awscfg and pass it to the manager.go and call newResourceManager with the awscfg as an additional parameter which will now include the awscfg.Endpoint and will now use this endpoint when creating the service client.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementCategorizes issue or PR as related to existing feature enhancements.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions