Skip to content

Calling AddSystemsManager using a profile that assumes role throws exception #864

@kpenergy

Description

@kpenergy

Description

When using a profile that assumes a role (no MFA involved), calling the AddSystemsManager extension method from within Visual Studio 2019 using the Mock Lambda Test Tool throws an exception:

System.InvalidOperationException: 'Assembly AWSSDK.SecurityToken could not be found or loaded. This assembly must be available at runtime to use Amazon.Runtime.AssumeRoleAWSCredentials.'

I'd expect that the correct role is assumed and the relevant parameters are fetched when calling the AddSystemsManager extension method. I think this is a bug as I cant see anything wrong on my end.

There's a similar issue open, #155, however the comments on it suggest that is specifically an issue because of MFA. The issue I'm facing has nothing to do with MFA (or at least, neither my account nor my credentials profile uses any MFA).

Reproduction Steps

Credentials file

[default]
aws_access_key_id=my_key
aws_secret_access_key=my_secret
region=eu-west-1

[profile-assumes-role]
role_arn = arn:aws:iam::my_account:role/my_role
source_profile = default
region=eu-west-1

appsettings.Development.json file

{
  "AWS": {
    "Region": "eu-west-1",
    "Profile": "profile-assumes-role"
  }
}

Code

public class Function
{
    public void FunctionHandler()
    {
        var config = new ConfigurationBuilder()
            .SetBasePath(Directory.GetCurrentDirectory())
            .AddJsonFile("appsettings.Development.json")
            .AddSystemsManager("/path-to-parameters/") // throws ex after brief wait
            .Build();
    }
}

Project Dependencies

<PackageReference Include="Amazon.Extensions.Configuration.SystemsManager" Version="2.1.0" />
<PackageReference Include="Amazon.Lambda.Core" Version="1.2.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.1.0" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />

Logs

Not sure how to get logs. The link mentioned in the bug template is specifically for .Net Framework. It points me to another page for .Net Core which has no information on logging.

Environment

  • Build Version: See dependency versions above
  • OS Info: Windows 10
  • Build Environment: Visual Studio 2019
  • Targeted .NET Platform: .Net Core 3.1

Resolution

  • 👋 I can/would-like-to implement a fix for this problem myself

This comment on issue #155 mention that AWSSDK.SecurityToken assembly needs to be added to the list of dependencies, however there would be further issues with MFA because the Lambda tooling doesnt support a prompt for MFA token. Perhaps this assembly should be added as a dependency regardless of the missing MFA prompt, which may fix the issue I'm seeing?


This is a 🐛 bug-report

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions