Skip to content

WebDiscover: allow setting labels when enrolling aws app#50976

Merged
kimlisa merged 2 commits intomasterfrom
lisa/aws-app-labels-ui
Jan 14, 2025
Merged

WebDiscover: allow setting labels when enrolling aws app#50976
kimlisa merged 2 commits intomasterfrom
lisa/aws-app-labels-ui

Conversation

@kimlisa
Copy link
Copy Markdown
Contributor

@kimlisa kimlisa commented Jan 13, 2025

part of #46976

requires #50975

image

with some labels

image

changelog: Adds support for defining labels in the web UI for AWS console access application

Comment thread web/packages/teleport/src/services/integrations/types.ts
Comment thread web/packages/teleport/src/services/integrations/integrations.ts Outdated
Comment thread web/packages/teleport/src/services/integrations/integrations.ts Outdated
Comment thread web/packages/teleport/src/services/integrations/integrations.ts Outdated
Comment on lines +302 to +306
return api
.post(cfg.getAwsAppAccessUrl(integrationName), req)
.then(makeApp);
}

return (
api
.post(cfg.getAwsAppAccessUrlV2(integrationName), req)
.then(makeApp)
// TODO(kimlisa): DELETE IN 19.0
.catch(withUnsupportedLabelFeatureErrorConversion)
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think the new UI should always use the new endpoint regardless if labels exist or not. The only time an "old" endpoint should be used is if we want some sort of graceful fallback in some feature which we don't care about here.

go all in!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i might be just confused, but i added the fallback so that the user has the option to proceed without the labels if they keep hitting the old proxy?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thats right. But this block of code reads like it will hit v1 if they didnt add any labels. I think they should always hit v2 even without labels

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But this block of code reads like it will hit v1 if they didnt add any labels.

i think that's okay, since either endpoint in new proxy uses the same handler

I think they should always hit v2 even without labels

hrm, but what if they hit an old proxy? get an error, and they get stuck? (the fallback is then to just remove labels and it will use the old endpoint in case it hits the old proxy again)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i mean they should always hit v2 as the happy path, even if they dont want to add labels. they are optional, so they should always go v2 since v2 should be able to handle it.
if the web hits the 404, they can be given the option to fallback to v1, sure. but we should never be hitting v1 if we havent already got the 404

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ah i think i finally understand the problem. calling v1 without labels will have issues once we remove the old endpoint, great catch 👍

@kimlisa kimlisa force-pushed the lisa/aws-app-labels-ui branch from ec3e23d to db5de3c Compare January 13, 2025 20:01
@kimlisa kimlisa changed the base branch from master to lisa/aws-app-labels January 13, 2025 20:04
@kimlisa kimlisa changed the base branch from lisa/aws-app-labels to master January 13, 2025 20:05
@kimlisa kimlisa force-pushed the lisa/aws-app-labels-ui branch from db5de3c to 0e1787d Compare January 13, 2025 20:06
@kimlisa kimlisa force-pushed the lisa/aws-app-labels-ui branch from 0e1787d to 42721df Compare January 13, 2025 20:17
Comment on lines +53 to 80
const [requiresProxyUpgrade, setRequiresProxyUpgrade] = useState(false);

const [attempt, createApp] = useAsync(async () => {
const labelsMap: Record<string, string> = {};
labels.forEach(l => (labelsMap[l.name] = l.value));
try {
const app = await integrationService.createAwsAppAccess(
awsIntegration.name
);
let app: App;
if (requiresProxyUpgrade && !labels.length) {
app = await integrationService.createAwsAppAccess(awsIntegration.name);
} else {
app = await integrationService.createAwsAppAccessV2(
awsIntegration.name,
{ labels: labelsMap }
);
}
updateAgentMeta({
...agentMeta,
app,
resourceName: app.name,
});
} catch (err) {
if (err.message.includes(ProxyRequiresUpgrade)) {
setRequiresProxyUpgrade(true);
}
emitErrorEvent(err.message);
throw err;
}
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make V2 the first API call the default one here as well? And looks like we can remove the const [requiresProxyUpgrade, setRequiresProxyUpgrade] = useState(false); state.

const [attempt, createApp] = useAsync(async () => {
    const labelsMap: Record<string, string> = {};
    labels.forEach(l => (labelsMap[l.name] = l.value));
    let app: App;
    try {
      app = await integrationService.createAwsAppAccessV2(
        awsIntegration.name,
        { labels: labelsMap }
      );
      }
    } catch (err) {

      if (err.message.includes(ProxyRequiresUpgrade)) {
      try {
        // retry to V1 endpoint
        app = await integrationService.createAwsAppAccess(awsIntegration.name);
      } catch (e) {
        emitErrorEvent(err.message);
        throw err;
      }
      emitErrorEvent(err.message);
      throw err;
    }
    updateAgentMeta({
      ...agentMeta,
      app,
      resourceName: app.name,
    });
  });

we can abstract v1 async call so catch(err) block is a bit simpler.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hrmmm, wouldn't this re-try for the user? i think it's better if user intentionally retries (by removing labels, which means they understand labels aren't going to be added) or abort altogether

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You are right this auto retries. Also letting user manually do that is a good idea.
I didn't see any label/copy updated for user based on requiresProxyUpgrade so recommended that alternative.
How would the retry UX look like?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

here is a recording of retry (the error message is there after the first attempt that seemed to have cut off from recording):

Screen.Recording.2025-01-13.at.10.09.52.PM.mov

I didn't see any label/copy updated for user based on requiresProxyUpgrade so recommended that alternative.

unless you feel strongly, i will leave it as is. i think it makes things too complicated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gotcha. That looks good to me. The only extra thing I could suggest is to mark the labels fields as error so it becomes more apparent but i wouldn't stress that if it begs more changes. Its good as is too.

@kimlisa kimlisa added this pull request to the merge queue Jan 14, 2025
Merged via the queue into master with commit 124026d Jan 14, 2025
@kimlisa kimlisa deleted the lisa/aws-app-labels-ui branch January 14, 2025 19:14
@public-teleport-github-review-bot
Copy link
Copy Markdown

@kimlisa See the table below for backport results.

Branch Result
branch/v17 Failed

kimlisa added a commit that referenced this pull request Jan 14, 2025
* WebDiscover: allow setting labels when enrolling aws app

* Address CRs
kimlisa added a commit that referenced this pull request Jan 15, 2025
* WebDiscover: allow setting labels when enrolling aws app

* Address CRs
kimlisa added a commit that referenced this pull request Jan 15, 2025
* WebDiscover: allow setting labels when enrolling aws app

* Address CRs
github-merge-queue Bot pushed a commit that referenced this pull request Jan 15, 2025
…ingle resource enroll (#51038)

* WebDiscover: allow setting resource labels when enrolling single eks, rds, server, kube (#50606)

* WebDiscover: Allow setting labels when enrolling single web application (#50853)

* Allow labels for generic add web app flow

* Update test

* WebDiscover: allow setting labels when enrolling aws app (#50976)

* WebDiscover: allow setting labels when enrolling aws app

* Address CRs

* Web: Fix v1 fallback with v2 endpoints (#51058)

* Implement a fallback hook for re-use

* Split v1 and v2 endpoints into separate funcs

* Provide fallback for create app access

* Provide fallback for join token suspender

* Provide fallback for eks

* Provide fallback for app

* Address CRs
mvbrock pushed a commit that referenced this pull request Jan 18, 2025
* WebDiscover: allow setting labels when enrolling aws app

* Address CRs
carloscastrojumo pushed a commit to carloscastrojumo/teleport that referenced this pull request Feb 19, 2025
…al#50976)

* WebDiscover: allow setting labels when enrolling aws app

* Address CRs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants