-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add ecs and eks imds ip adresses to greengrass list #1288
Conversation
what are the ENV vars and config file data needed to reproduce the issue? |
please provide, in addition to the environment variables and config file data, a code sample used to initialize an SDK client and perform the first request |
Thanks George ENV (those that are relevant): - name: AWS_CONFIG_FILE
value: /workdir/.aws/config
- name: AWS_STS_REGIONAL_ENDPOINTS
value: regional
- name: AWS_DEFAULT_REGION
value: ap-southeast-2
- name: AWS_REGION
value: ap-southeast-2
- name: AWS_CONTAINER_CREDENTIALS_FULL_URI
value: 'http://169.254.170.23/v1/credentials'
- name: AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE
value: >-
/var/run/secrets/pods.eks.amazonaws.com/serviceaccount/eks-pod-identity-token /workdir/.aws/config # Content of the AWS Config file
[default]
source_profile = cluster_role
role_arn = arn:aws:iam::1234567890:role/some-role
[profile cluster_role]
credential_source=EcsContainer getSSMParameter.ts import { GetParameterCommand, SSMClient } from '@aws-sdk/client-ssm';
export const getSSMParameter = async () => {
const client = new SSMClient({}); // Default credential chain!
const command = new GetParameterCommand({
Name: 'my-param',
});
const response = await client.send(command);
return response.Parameter?.Value;
}; |
It looks like you want this sequence to happen based on that information:
is that correct? Secondly, can you provide the output of using the default credential chain (except explicitly) and providing it a logger? import { STS } from "@aws-sdk/client-sts";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
const client = new STS({
credentials: defaultProvider({
logger: console,
}),
});
await client.getCallerIdentity(); The output should look something like
and it indicates the order of credential providers attempted in the chain. |
Yes that's exactly what I'm trying to do :) Logs as requested (baseline):
After applying this patch:
☝️ Succeeds to get creds but not assume the role in the config file In other news I've had a small win. I've managed to patch both your change here aws/aws-sdk-js-v3#6132 AND the changes in this PR into my test harness. The role assumption is successful when i use the following config (the one i quoted above using # Content of the AWS Config file. This works!!!
[default]
role_arn = arn:aws:iam::1234567890:role/some-role
credential_source=EcsContainer ...and the logs to go with it:
|
I think I have a full picture of the issue now, and fixes will be applied in the linked PRs. Here is a summary:
Both bugs are planned to be addressed by aws/aws-sdk-js-v3#6132. Release is pending review and testing. After the patch the credential debug output should look like this:
That is, it should go directly from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be fixed in aws/aws-sdk-js-v3#6132
That all makes sense George thank you for following up on this 🙏 |
The AWS Profile EcsContainer credential provider is broken for application code running within the EKS environment using the AWS Pod Identity Service for credentials. This is because the AWS JSv3 SDK (using this library) configures itself using the fromContainerMetadata method which has an allow-list to only the ECS service (or localhost).
The EcsContainer credential provider is intended to be used with either ECS or EKS credential services (see https://docs.aws.amazon.com/sdkref/latest/guide/feature-container-credentials.html). This library restricts this provider to usage only with the ECS credential service.
This PR allow-lists the EKS credential service in addition to the ECS service to match the supported use-cases when configuring from the AWS profile config. This brings the AWS JSv3 SDK (which is supported) which uses this library back into feature-parity with the other SDKs supporting the EKS Pod Identity Service such as the Go SDK.
It’s been noted in other PRs/issues around this issue that the fromHttp method can be used for the EKS Pod Identity Service. This is correct however this is for programmatic configuration whereas this PR fix is about fixing the supported use-case of configuring the SDK via the AWS Profile Config.
Note1: Equivalent PR from November 2023 in the Go SDK
Note2: this is effectively reopening #1144