-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Powershell NetCore does not work with AWS_WEB_IDENTITY_TOKEN_FILE #243
Comments
Hi @iguyking, Good morning. Could you please confirm the following:
Some issues are resolved after cluster upgrade as was the case in aws/aws-sdk-net#1615. Thanks, |
EKS version is 1.20 AWS_ROLE_ARN & AWS_WEB_IDENTITY_TOKEN_FILE are set and work properly for the python based aws cli commands. I ran the aws cli & powershell commands in the same OS/same docker container session. That ticket is around Windows based OSes. This is from an ubuntu 20.04 image. |
What can I help give you to see this work or not work? |
Update: EKS version 1.21.5-20211117 Still not working where the aws python works.
Test info:Create a new role called powershell-test-role in the account & update the trust to match your EKS cluster for IRSA Setup a standard EKS Cluster Connect in over kubectl exec
|
Reproducible with output of STEPS:
Namespace is
apiVersion: apps/v1
kind: Deployment
metadata:
name: ubuntu
labels:
app: ubuntu
namespace: kube-system
spec:
selector:
matchLabels:
app.kubernetes.io/name: ubuntu
replicas: 1
template:
metadata:
name: ubuntu
labels:
app.kubernetes.io/name: ubuntu
spec:
serviceAccountName: "my-serviceaccount"
nodeSelector:
beta.kubernetes.io/arch: amd64
containers:
- name: ubuntu
image: "ubuntu:20.04"
imagePullPolicy: Always
command: ["/bin/sh"]
args: ["-c", "while true; do echo hello; sleep 10;done"]
{
"UserId": "AROASA6NRDFTRA3E5WHQ2:botocore-session-1643830450",
"Account": "139480602983",
"Arn": "arn:aws:sts::<<ACCOUNT-ID>>:assumed-role/eksctl-ubuntu-powershell-test-addon-iamservi-Role1-1ENWEJZZEEZNE/botocore-session-1643830450"
}
It produces the below output:
Notice that output of |
I encountered the same issue and managed to find a workaround: Import-Module AWSPowershell.NetCore
$AWS_CREDS = Use-STSWebIdentityRole -RoleArn $env:AWS_ROLE_ARN -RoleSessionName $env:HOSTNAME -WebIdentityToken $(gc $env:AWS_WEB_IDENTITY_TOKEN_FILE) -Select 'Credentials'
Set-AWSCredential -Credential $AWS_CREDS
Get-STSCallerIdentity Haven't refactored my workload yet, but I guess I would need to implement logic to ensure the creds are periodically updated. |
Thanks so much, abstrask! This worked, but still weird why we have to do this. I end up adding this to my scripts so I can still run them both in pods or on EC2 instances.
|
Description
Attempting to utilize AWS Powershell Netcore tooling with EKS using IRSA credentials which supply the AWS_WEB_IDENTITY_TOKEN_FILE environment variable and file for getting credentials for a kubernetes pod. When making calls such as Use-STSCallerIdentity, the AWS cmdlets do not find the Web Identity Token information. Instead it is defaulting to the node's instance profile.
Reproduction Steps
Create a basic Ubuntu Docker Image with .NET 5 (latest) and Powershell Core downloaded.
Install AWSPowershell.NetCore version 4.1.15.0.
Setup EKS with the recommended IRSA configuration and assign this role to the deployment pod in question
Run
Get-STSCallerIdentity
This will return the node's IAM role, not the Pods.
AWS CLI will return correctly:
Powershell call will return
Environment
Resolution
This is a 🐛 bug-report
The text was updated successfully, but these errors were encountered: