Skip to content

Bug: Use-STSWebIdentityRole Returns No Credentials in PowerShell (Only Expiration field is Returned) #362

@dotNetNaji

Description

@dotNetNaji

Describe the bug

Issue Description: I am encountering an issue with the Use-STSRoleWithWebIdentity cmdlet in AWS Tools for PowerShell when running it in a Bitbucket Pipeline. The cmdlet returns an object that contains ONLY the Expiration value. The AWS CLI, using the same parameters (role ARN, web identity token, session name, etc.), works as expected and returns the full credentials (AccessKeyId, SecretAccessKey, and SessionToken).

Regression Issue

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

Expected Behavior

The Use-STSRoleWithWebIdentity cmdlet should return the full credentials (similar to the AWS CLI), including the AccessKeyId, SecretAccessKey, and SessionToken.

Current Behavior

The Credentials object in the response contains only the Expiration field.
No errors or exceptions are thrown, but the complete credentials are missing from the response.

Reproduction Steps

Environment:
Bitbucket Pipeline (using mcr.microsoft.com/dotnet/sdk:8.0 image)
AWS Tools for PowerShell version: 4.1.680
PowerShell version: 7.5.4
AWS region: eu-west-1

PowerShell Code: (Running inside a bitbucket pipeline)

$stsResponse = Use-STSRoleWithWebIdentity `
        -RoleArn $env:PIPELINE_ROLE_ARN `
        -RoleSessionName "build-session" `
        -WebIdentityToken $env:BITBUCKET_STEP_OIDC_TOKEN `
        -DurationSeconds 3600

    # Output response to verify
    $stsResponse | ConvertTo-Json -Depth 10 | Write-Host

Output :

{
  "Expiration": "2024-10-18T20:27:47+00:00"
}

AWS CLI Command (Works as expected):

aws sts assume-role-with-web-identity \
      --role-arn $PIPELINE_ROLE_ARN \
      --role-session-name session-name \
      --web-identity-token $BITBUCKET_STEP_OIDC_TOKEN \
      --duration-seconds 3600

CLI output

{
  "Credentials": {
    "AccessKeyId": "AKIA...",
    "SecretAccessKey": "wJalrX...",
    "SessionToken": "IQoJb...",
    "Expiration": "2024-10-18T20:27:47+00:00"
  },
  "AssumedRoleUser": {
    "AssumedRoleId": "AROAXXXXXXXXXXXX:build-session",
    "Arn": "arn:aws:sts::XXXXXXXXXX:assumed-role/my-role/build-session"
  }
}

Possible Solution

No response

Additional Information/Context

Bitbucket Pipelines OIDC is configured correctly as the AWS CLI works without issue.
No errors or exceptions are thrown in PowerShell; it simply returns an object with only Expiration field.

AWS Tools for PowerShell version used

Name : AWS.Tools.Common
Version : 4.1.680

Name : AWS.Tools.SecurityToken
Version : 4.1.680

PowerShell version used

Major : 7
Minor : 4
Patch : 5
PreReleaseLabel :
BuildLabel :

Operating System and version

Ubuntu

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closing-soonThis issue will automatically close in 4 days unless further comments are made.module/powershell-cmdletsp2This is a standard 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