Skip to content

[Web] Add Discover flow for enrolling EC2 Instances with EICE#32202

Merged
rudream merged 1 commit intomasterfrom
yassine/ec2ice/flow
Sep 28, 2023
Merged

[Web] Add Discover flow for enrolling EC2 Instances with EICE#32202
rudream merged 1 commit intomasterfrom
yassine/ec2ice/flow

Conversation

@rudream
Copy link
Copy Markdown
Contributor

@rudream rudream commented Sep 20, 2023

Purpose

Part of #29317

Adds a Discover flow to enroll an AWS EC2 Instance using an EC2 Instance Connect Endpoint.

PR for usage events: #32617

Flow

  • Step 1: The user selects the AWS OIDC integration to use. If they don't have any, they can be redirected to the steps to add the integration, and after that they will be returned to the Discover flow. (This is the same behaviour as the first step for RDS).

  • Step 2: The user selects the AWS region they want to list EC2 instances for and selects the EC2 instance they want to enroll. If there is an AWS-related permissions error that prevents them from listing their EC2 instances, we show a CloudShell script that they can run which will configure the required IAM permissions.

    • At this stage, we check whether or not there is already an EC2 Instance Connect Endpoint (EICE) that exists in that VPC.

    • If there are no already existing EICE's, we go to step 3 where we create one.

    • If there is an EICE, and it is in state create-complete (meaning it has been created and is ready to be used), we skip step 3 and 4 and go straight to step 5 where the Teleport node is created.

    • If there is an EICE but it is in state create-in-progress, then we skip step 3 and go straight to step 4 and wait for it to become create-complete.

  • Step 3: The user selects security groups that they want to assign to the new EICE that is about to be created. Selecting security groups here is optional. Once they click Next, we deploy the new EICE and a dialog is shown.

  • Step 4: The dialog shows a loading bar and waits for the EICE to be in the create-complete state, until then, it will be create-in-progress. It will poll every 10 seconds to check the state of the EICE.

    • If the state is create-failed, we display an error message letting the user know that there was an error during the creation process and provide them with a link to their AWS dashboard where they can troubleshoot the problem or manually create the EICE. We still continue polling so that if they do resolve the issue and the EICE becomes create-complete, we can continue the flow.
    • Once the state is create-complete, we automatically go to step 5. The user doesn't have to click anything.
  • Step 5: Still in the same dialog, we create the Teleport node, this only take a couple of seconds. After this they can proceed to the next step.

  • Step 6: The user configures the OS users that will be used to connect to the newly created node.

  • Step 7: The user can test the connection to the newly created node.

Demo

Select EC2 Instance

image

Select Security Groups

image

EICE Deployment Dialog

image

image

@public-teleport-github-review-bot
Copy link
Copy Markdown

@rudream - this PR will require admin approval to merge due to its size. Consider breaking it up into a series smaller changes.

Copy link
Copy Markdown
Contributor

@marcoandredinis marcoandredinis left a comment

Choose a reason for hiding this comment

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

Awesome job 💪

I left some comments.
The only blocker I'm seeing is the Test Connection part
Btw, I tested this locally and using Cloud Stage and both envs worked 👍

Comment thread api/proto/teleport/usageevents/v1/usageevents.proto Outdated
AssistAccessRequest assist_access_request = 38;
AssistAction assist_action = 39;
UIDiscoverEC2InstanceSelectionEvent ui_discover_ec2_instance_selection = 40;
UIDiscoverEICEDeployNodeCreateEvent ui_discover_eice_deploy_node_create = 41;
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.

Can we have two separate events here?
One for deploying the EICE and another one for creating the resource in teleport.

Comment thread web/packages/teleport/src/Discover/Server/TestConnection/TestConnection.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Server/EnrollEc2Instance/Ec2InstanceList.tsx Outdated
Copy link
Copy Markdown
Contributor

@kimlisa kimlisa left a comment

Choose a reason for hiding this comment

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

can you split this into two PRs:

  • events (including frontend bits)
  • web stuff

I generally try not to mix backend/frontend bits like this unless it's trivial or small (maybe this is what you meant if you should split, and sorry if i mislead you :)).

I will also split, if there are no dependency (or if one bit can block the entire PR from merging).

Copy link
Copy Markdown
Contributor

@kimlisa kimlisa left a comment

Choose a reason for hiding this comment

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

i'll take a closer look tomorrow while testing the e2e tomorrow

Comment thread web/packages/teleport/src/Discover/SelectResource/resources.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Server/ConnectAwsAccount/ConnectAwsAccount.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Server/CreateEc2Ice/CreateEc2IceDialog.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Shared/CommandBox.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Server/EnrollEc2Instance/EnrollEc2Instance.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Server/EnrollEc2Instance/EnrollEc2Instance.tsx Outdated
@ibeckermayer ibeckermayer removed their request for review September 25, 2023 20:21
@rudream rudream force-pushed the yassine/ec2ice/flow branch from 990dd5e to c6781d4 Compare September 26, 2023 22:28
@rudream rudream force-pushed the yassine/ec2ice/flow branch 3 times, most recently from f086bf2 to 3815d0d Compare September 27, 2023 14:47
@marcoandredinis
Copy link
Copy Markdown
Contributor

Backend looks good to me 👍
Given that frontend is 90% of the changes, I would rather have someone else look into it

Copy link
Copy Markdown
Contributor

@kimlisa kimlisa left a comment

Choose a reason for hiding this comment

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

with some minor comments, lgtm

please take care of particularly #32202 (comment) and the one below it

Comment thread web/packages/teleport/src/Discover/Database/EnrollRdsDatabase/RdsDatabaseList.tsx Outdated
Comment thread web/packages/teleport/src/Discover/SelectResource/resources.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Server/CreateEc2Ice/CreateEc2Ice.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Shared/index.ts Outdated
Comment thread web/packages/teleport/src/Discover/Shared/AwsAccount/AwsAccount.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Shared/AwsAccount/AwsAccount.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Server/index.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Server/CreateEc2Ice/CreateEc2IceDialog.tsx Outdated
Comment thread web/packages/teleport/src/Discover/Server/CreateEc2Ice/CreateEc2Ice.tsx Outdated
Copy link
Copy Markdown
Contributor

@avatus avatus left a comment

Choose a reason for hiding this comment

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

After the suggested fixes LGTM

Copy link
Copy Markdown
Collaborator

@r0mant r0mant left a comment

Choose a reason for hiding this comment

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

Bot 🎉

@rudream rudream force-pushed the yassine/ec2ice/flow branch from 39af7af to 423ab04 Compare September 28, 2023 16:22
@rudream rudream enabled auto-merge September 28, 2023 16:22
@rudream rudream added this pull request to the merge queue Sep 28, 2023
Merged via the queue into master with commit 10a1f2d Sep 28, 2023
@rudream rudream deleted the yassine/ec2ice/flow branch September 28, 2023 16:56
@public-teleport-github-review-bot
Copy link
Copy Markdown

@rudream See the table below for backport results.

Branch Result
branch/v13 Failed
branch/v14 Create PR

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.

5 participants