Skip to content
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

Integration Discovery Rules: endpoint that returns all the rules #49514

Merged
merged 2 commits into from
Dec 6, 2024

Conversation

marcoandredinis
Copy link
Contributor

This PR adds a new endpoint that returns all the discovery rules that exist for a given Integration.

It will include what was the last time the rule was used to fetch resources, so that users can see stale rules and act upon it.

The endpoint supports filtering by the resource type to ensure the UI only requests a subset of the rules, depending on the screen the user is visiting (eg, EC2, RDS or EKS).

Demo:

curl ... 'https://proxy.example.com/v1/webapi/sites/my-cluster/integrations/teleportdev/discoveryrules'

{
  "rules": [
    {
      "resourceType": "ec2",
      "region": "eu-west-2",
      "labelMatcher": [
        {
          "name": "*",
          "value": "*"
        }
      ],
      "discoveryConfig": "5c1c195c-51ba-43be-af88-c6d4cbd49b37",
      "lastSync": "2024-11-27T15:50:41.944853Z"
    },
    {
      "resourceType": "rds",
      "region": "eu-west-2",
      "labelMatcher": [
        {
          "name": "vpc-id",
          "value": "vpc-47381f2f"
        }
      ],
      "discoveryConfig": "baee1aa0-4cf3-45d3-a816-c961d3830b82",
      "lastSync": "2024-11-27T15:50:41.957849Z"
    },
    {
      "resourceType": "rds",
      "region": "eu-west-2",
      "labelMatcher": [
        {
          "name": "RunDiscover",
          "value": "PleaseNo"
        }
      ],
      "discoveryConfig": "dc001"
    },
    {
      "resourceType": "eks",
      "region": "eu-west-2",
      "labelMatcher": [
        {
          "name": "RunDiscover",
          "value": "PleaseNo"
        }
      ],
      "discoveryConfig": "dc001"
    },
    {
      "resourceType": "eks",
      "region": "eu-west-2",
      "labelMatcher": [
        {
          "name": "*",
          "value": "*"
        }
      ],
      "discoveryConfig": "e6402547-d9b4-492c-a426-1c4070cb0f33",
      "lastSync": "2024-11-27T15:50:41.952754Z"
    }
  ]
}

@github-actions github-actions bot requested a review from kiosion November 27, 2024 18:03
@github-actions github-actions bot requested a review from ravicious November 27, 2024 18:03
@marcoandredinis marcoandredinis force-pushed the marco/integration_rules_endpoint branch 2 times, most recently from 3b3425d to 2feaecc Compare November 28, 2024 18:35
lib/web/integrations.go Outdated Show resolved Hide resolved

ret.NextKey = nextToken

if nextToken == "" || len(ret.Rules) > maxPerPage {
Copy link
Member

Choose a reason for hiding this comment

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

So I suppose it can fetch more rules than maxPerPage, but I assume we're okay with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think so.
This works as a soft limit.
Otherwise, we might need to stop adding elements in the middle of the loop, which would turn the nextToken something composed of the DiscoveryConfig previous nextToken and some other value indicating where we stopped (some index).

@marcoandredinis marcoandredinis force-pushed the marco/integration_rules_endpoint branch from 2feaecc to 83e6a93 Compare November 29, 2024 14:09
This PR adds a new endpoint that returns all the discovery rules that
exist for a given Integration.

It will include what was the last time the rule was used to fetch
resources, so that users can see stale rules and act upon it.

The endpoint supports filtering by the resource type to ensure the UI
only requests a subset of the rules, depending on the screen the user is
visiting (eg, EC2, RDS or EKS).
@marcoandredinis marcoandredinis force-pushed the marco/integration_rules_endpoint branch from 83e6a93 to 4568fb7 Compare December 2, 2024 11:00
@marcoandredinis marcoandredinis added the no-changelog Indicates that a PR does not require a changelog entry label Dec 3, 2024
@marcoandredinis
Copy link
Contributor Author

@kiosion Can you please take a lookg when you get a chance?

@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from kiosion December 5, 2024 23:56
@marcoandredinis marcoandredinis added this pull request to the merge queue Dec 6, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 6, 2024
@marcoandredinis marcoandredinis added this pull request to the merge queue Dec 6, 2024
Merged via the queue into master with commit 6827ae1 Dec 6, 2024
40 of 41 checks passed
@marcoandredinis marcoandredinis deleted the marco/integration_rules_endpoint branch December 6, 2024 09:18
@public-teleport-github-review-bot

@marcoandredinis See the table below for backport results.

Branch Result
branch/v16 Failed
branch/v17 Create PR

marcoandredinis added a commit that referenced this pull request Dec 6, 2024
)

* Integration Discovery Rules: endpoint that returns all the rules

This PR adds a new endpoint that returns all the discovery rules that
exist for a given Integration.

It will include what was the last time the rule was used to fetch
resources, so that users can see stale rules and act upon it.

The endpoint supports filtering by the resource type to ensure the UI
only requests a subset of the rules, depending on the screen the user is
visiting (eg, EC2, RDS or EKS).

* use discovery rule
github-merge-queue bot pushed a commit that referenced this pull request Dec 6, 2024
) (#49869)

* Integration Discovery Rules: endpoint that returns all the rules

This PR adds a new endpoint that returns all the discovery rules that
exist for a given Integration.

It will include what was the last time the rule was used to fetch
resources, so that users can see stale rules and act upon it.

The endpoint supports filtering by the resource type to ensure the UI
only requests a subset of the rules, depending on the screen the user is
visiting (eg, EC2, RDS or EKS).

* use discovery rule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v16 backport/branch/v17 discover Issues related to Teleport Discover no-changelog Indicates that a PR does not require a changelog entry size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants