Skip to content

delete-function command doesn't respect AWS_DEFAULT_PROFILE variable #359

@tolache

Description

@tolache

Describe the bug

If you are not using a default profile set in ~/.aws/config and rely on setting the AWS_DEFAULT_PROFILE environment variable to select the required profile, the dotnet lambda delete-function command will fail unless a profile is specified inline.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

The function is deleted successfully.

Current Behavior

dotnet lambda delete-function --function-name <my_function_name> produces output indicating an error:

Amazon Lambda Tools for .NET Core applications (5.12.3)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet

Error deleting Lambda function: Unable to get IAM security credentials from EC2 Instance Metadata Service.

Reproduction Steps

  1. Ensure that there is not default credentials in .aws/credentials.
  2. Set AWS_DEFAULT_PROFILE to <my_non_default_profile>.
  3. Ensure aws sts get-caller-identity works, i.e., provides output like
    {
        "UserId": "<my_user_id>",
        "Account": "<my_account_id>",
        "Arn": "arn:aws:iam::<my_account_id>:user/<my_non_default_profile>"
    }
    
  4. Deploy a function using dotnet lambda deploy-function.
  5. Try to delete the function using dotnet lambda delete-function --function-name <my_function_name>.

Possible Solution

The workaround is to specify the non-default profile inline:

dotnet lambda delete-function --function-name TunnelGPT --profile <my_non_default_profile>

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon Lambda Tools for .NET Core applications (5.12.3)

Targeted .NET Platform

.NET 8

Operating System and version

Windows 11

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.module/cli-extp3This is a minor priority issueresponse-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions