Skip to content

Conversation

@liramon1
Copy link

@liramon1 liramon1 commented Jul 8, 2025

Problem

The identity LSP does not support saving and loading IAM profiles. This forces IDE extensions to manage their own IAM profiles, which leads to code duplication and added complexity.

Solution

This is part of #1981.

This PR introduces 4 new IAM-related profile types that aim to be compliant with the AWS CLI: IamCredentialsProfile, IamSourceProfileProfile, IamCredentialSourceProfile, and IamCredentialProcessProfile. The identity LSP has been modified to save and load these new profile types, in addition to the SsoTokenProfile, from the shared config files. These changes lay the groundwork for retrieving IAM credentials in the next few PRs, since language clients can update profile fields to specify how to obtain IAM credentials.

Note: This PR currently fails the CI pipeline because it depends on changes from aws/language-server-runtimes#599.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@liramon1 liramon1 requested a review from a team as a code owner July 8, 2025 13:43
@liramon1 liramon1 marked this pull request as draft July 9, 2025 19:51
optional: [ProfileFields.region],
disallowed: [ProfileFields.sso_account_id, ProfileFields.sso_role_name],
},
IamUserProfile: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The terminology specified in the AWS CLI and SDK and Tools public docs is generally "short-term"/"temporary" credentials (when containing a aws_session_token) or "long-term" credentials (when not). Either way they're just "IAM credentials". The short-term credentials can only represent roles, not users. The long-term can represent both. I think storing both long-term and short-term in the same type with an optional aws_session_token is fine, but the name should probably be IamCredentialsProfile.

],
disallowed: [ProfileFields.credential_source],
},
IamRoleInstanceProfile: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this type of profile can be used for containers as well and to be consistent with IamRoleSourceProfile naming, I would suggest renaming this to IamRoleCredentialSourceProfile (clearly indicating that the credential_source field is being used instead of the source_profile field.

I'd also suggest dropping the Role designation. While roles are more commonly used these days and users aren't supported with some types of profiles, profiles (aside from SSO token profiles) result in just IAM credentials, whether they were generated from a role or user is generally inconsequential.

optional: [ProfileFields.external_id, ProfileFields.role_session_name, ProfileFields.region],
disallowed: [ProfileFields.source_profile],
},
IamProcessProfile: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For conistent naming, use IamCredentialProcessProfile.

this.throwOnInvalidProfile(!params.profile, 'Profile required.')
const profile = params.profile!

// Removing this check for profile deletion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this comment mean in this context? Is it supposed to be here?

Also, nothing to do with your PR, but seems like the original code here might've been written before the DuckTypers as this seems to be redundant with what it does. Consider adding a // TODO Can this be refactored and simplified using the existing DuckTypers? here. Don't worry about looking it any further for this project though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, that comment was supposed to be removed. It was in reference to using updateProfile to invalidate credential fields. The plan now is to allow language clients to invalidate credential fields by calling updateProfile with an Unknown profile kind. Note that they cannot invalidate using the IAM profile kinds because the credential fields must be non-null for their duck typers to pass.

const relevantFields = [...fields.required, ...fields.optional]
for (const field of relevantFields) {
if (settings[field] !== undefined) {
profile.settings![field] = settings[field]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did TS required the ! after settings given it's explicitly defined in line 53 above?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes TS still requires ! . I think it's because the settings field is optional in the Profile interface definition.

accessKeyId: string
secretAccessKey: string
sessionToken?: string
expiration?: Date
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this field used?

Copy link
Author

@liramon1 liramon1 Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, this PoC version of IamCredentials isn't used. I confused it with this. The expiration field on the runtimes IamCredentials is used in this PR to ease conversions to/from StsCredential (analogous to SSOToken from the SSO cache) and decide when to refresh the credential.

@liramon1 liramon1 changed the base branch from main to liramon/flare-iam July 16, 2025 18:50
@liramon1 liramon1 deleted the branch aws:feature/flare-iam-base July 16, 2025 18:57
@liramon1 liramon1 closed this Jul 16, 2025
@liramon1 liramon1 reopened this Jul 16, 2025
@liramon1 liramon1 changed the base branch from liramon/flare-iam to feature/flare-iam-base July 16, 2025 19:00
ctlai95 and others added 3 commits July 16, 2025 12:33
* test: codecov integration

* add coverage script for chat-client and lsp core

* add c8 configs

* use js files for coverage
* feat: add conversation compaction

* fix: address comments

* fix: add unit tests

* fix: fix unit tests
Will-ShaoHua and others added 17 commits July 16, 2025 16:22
* fix: add active user tracker and emit metrics

* fix: add time window state persistence across IDE restarts

* fix: lint
* fix: align auto trigger classifier with documentChangeEvent

* fix: add unit test
* fix(amazonq): replacing image's large binary in log

* fix(amazonq): replacing image's large binary in log
* fix: treat `echo`/`find`/`grep` as mutating

as discussed in internal channels

* tst
* chore(release): release packages from branch main

* build: add missing packagelock file (aws#1927)

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Will Lo <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2025

Codecov Report

❌ Patch coverage is 77.65326% with 339 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (feature/flare-iam-base@99d2f70). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...nguage-server/agenticChat/agenticChatController.ts 54.48% 264 Missing ⚠️
chat-client/src/client/mynahUi.ts 17.39% 19 Missing ⚠️
...ge-server/inline-completion/codeWhispererServer.ts 56.09% 17 Missing and 1 partial ⚠️
...-lsp-codewhisperer/src/shared/activeUserTracker.ts 93.19% 12 Missing and 1 partial ⚠️
...language-server/agenticChat/tools/chatDb/chatDb.ts 92.18% 10 Missing ⚠️
core/aws-lsp-core/src/util/processUtils.ts 80.76% 5 Missing ⚠️
...r/agenticChat/context/additionalContextProvider.ts 92.68% 3 Missing ⚠️
...r/agenticChat/context/agenticChatTriggerContext.ts 97.36% 1 Missing ⚠️
...ver/agenticChat/context/contextCommandsProvider.ts 50.00% 1 Missing ⚠️
.../language-server/agenticChat/qAgenticChatServer.ts 66.66% 1 Missing ⚠️
... and 4 more
Additional details and impacted files
@@                    Coverage Diff                    @@
##             feature/flare-iam-base    #1845   +/-   ##
=========================================================
  Coverage                          ?   65.96%           
=========================================================
  Files                             ?      238           
  Lines                             ?    50623           
  Branches                          ?     3385           
=========================================================
  Hits                              ?    33393           
  Misses                            ?    17170           
  Partials                          ?       60           
Flag Coverage Δ
unittests 65.96% <77.65%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@liramon1 liramon1 merged commit 1491f4f into aws:feature/flare-iam-base Jul 18, 2025
5 checks passed
liramon1 added a commit to liramon1/language-servers that referenced this pull request Jul 24, 2025
The identity LSP was changed to load and save IAM profile kinds.
liramon1 added a commit to liramon1/language-servers that referenced this pull request Jul 24, 2025
The identity LSP was changed to load and save IAM profile kinds.
liramon1 added a commit to liramon1/language-servers that referenced this pull request Jul 24, 2025
The identity LSP was changed to load and save IAM profile kinds.
liramon1 added a commit that referenced this pull request Jul 25, 2025
The identity LSP was changed to load and save IAM profile kinds.
liramon1 added a commit that referenced this pull request Jul 25, 2025
The identity LSP was changed to load and save IAM profile kinds.
liramon1 added a commit that referenced this pull request Jul 28, 2025
The identity LSP was changed to load and save IAM profile kinds.
liramon1 added a commit that referenced this pull request Jul 30, 2025
The identity LSP was changed to load and save IAM profile kinds.
liramon1 added a commit that referenced this pull request Aug 1, 2025
The identity LSP was changed to load and save IAM profile kinds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.