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

feat: Collect DNS records from NS1 #629

Merged
merged 1 commit into from
Jan 15, 2024
Merged

feat: Collect DNS records from NS1 #629

merged 1 commit into from
Jan 15, 2024

Conversation

akash1810
Copy link
Member

@akash1810 akash1810 commented Dec 29, 2023

What does this change, and why?

The NS1 source plugin (https://github.com/guardian/cq-source-ns1) is written in TypeScript, and distributed as a Docker image.

Previous attempts (see #337) to use this plugin failed, because ECS containers cannot interact with Docker (see aws/containers-roadmap#1356).

In this change, we run the NS1 source plugin directly, in its own container, resulting in a GRPC server on localhost:7777. We then configure the CloudQuery sync container to connect to this endpoint.

Collecting this data provides more information about our running services. For example, we can identify which services use Fastly, CloudFront, or no CDN.

We can also use this data to identify "dangling DNS records". That is, records whose answer no longer exist, and thus should be deleted, saving on the limited number of records available to us.

Resulting architecture

Standard task

flowchart TD
    A[Fire Lens] --> B(CloudQuery Sync)
Loading

NS1 task

flowchart TD
    A[Fire Lens] --> C(CloudQuery Sync to localhost:7777)
    B[CloudQuery NS1] --> C(CloudQuery Sync to localhost:7777)
Loading

How has it been verified?

Deployed to CODE, ran the task, and seen NS1 data in Grafana CODE 🎉.

Note

The NS1 API key used in CODE has been copied from https://github.com/guardian/dns-validation-lambda in CODE. This key has been limited to particular zones. We'd need to generate a new API key, with read-only access to all zones.

@akash1810 akash1810 force-pushed the aa/ns1-again branch 6 times, most recently from e8d50ae to 62ebf8d Compare December 29, 2023 17:34
@akash1810 akash1810 marked this pull request as ready for review December 29, 2023 17:57
@akash1810 akash1810 requested review from a team as code owners December 29, 2023 17:57
@akash1810 akash1810 force-pushed the aa/ns1-again branch 2 times, most recently from 4ff64a7 to 748507c Compare January 2, 2024 10:03
Copy link
Member

@AshCorr AshCorr left a comment

Choose a reason for hiding this comment

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

Nice 👌

*
* @see https://docs.cloudquery.io/docs/reference/source-spec
*/
dockerDistributedPluginImage?: RepositoryImage;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
dockerDistributedPluginImage?: RepositoryImage;
additionalPluginImage?: RepositoryImage;

or

Suggested change
dockerDistributedPluginImage?: RepositoryImage;
pluginContainer?: RepositoryImage;

Think this would work with any kind of Container image right? Not just Docker images?

Copy link
Member Author

Choose a reason for hiding this comment

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

I used docker here as a way to distinguish CloudQuery plugins written in Go, vs not-Go. The former is distributed as a binary, and the latter as a Docker image, see https://docs.cloudquery.io/docs/developers/creating-new-plugin/javascript-source#releasing-and-deploying-your-plugin.

{
image: dockerDistributedPluginImage,
logging: fireLensLogDriver,
essential: false,
Copy link
Member

Choose a reason for hiding this comment

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

I think this container would be essential no? I guess the main CloudQuery container will crash either way so probably not that important.

Copy link
Member Author

Choose a reason for hiding this comment

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

I got an error from this previously... I can't remember the exact error, I've a vague memory that CloudFormation failed to deploy the change.

packages/cdk/lib/cloudquery/task.ts Outdated Show resolved Hide resolved
@akash1810 akash1810 force-pushed the aa/ns1-again branch 2 times, most recently from 95fb79d to 154c931 Compare January 3, 2024 08:42
@mchv
Copy link
Member

mchv commented Jan 4, 2024

A new read-only API key has now been created and is ready to be used.

@akash1810 akash1810 force-pushed the aa/ns1-again branch 2 times, most recently from 139be33 to 8091f18 Compare January 15, 2024 08:58
@akash1810 akash1810 merged commit 9dda555 into main Jan 15, 2024
2 checks passed
@akash1810 akash1810 deleted the aa/ns1-again branch January 15, 2024 09:46
@akash1810
Copy link
Member Author

In this change, we run the NS1 source plugin directly, in its own container, resulting in a GRPC server on localhost:7777. We then configure the CloudQuery sync container to connect to this endpoint.

Confirming this is how CloudQuery suggest doing this too! https://docs.cloudquery.io/docs/advanced-topics/using-cloud-query-docker-registry-plugins-inside-a-containerized-environment

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.

3 participants