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

Create "obligatron" lambda #989

Merged
merged 5 commits into from May 21, 2024
Merged

Create "obligatron" lambda #989

merged 5 commits into from May 21, 2024

Conversation

AshCorr
Copy link
Member

@AshCorr AshCorr commented May 9, 2024

What does this change?

Creates a new "obligatron" lambda which evaluates service-catalogue data and decides if its compliant with obligations.

Why?

This lays some of the groundwork for writing the business logic for some of the obligations the Ops team is working on (and maybe Security and Reliability too?).

Eventually this lambda should provide a framework for fetching data from Service Catalogue and saving it to a results table in a generic way so that when writing a new obligation the developer only has to worry about parsing the data, and not establish a DB connection or saving the results to a table.

In the short term this lambda will evaluate the Ops TAGGING obligation by fetching data from the aws_resources view, filtering out AWS managed resources, and validating them against our tagging schema.

How has it been verified?

Ran locally.

@AshCorr AshCorr force-pushed the mob/obligatron branch 10 times, most recently from 0a4b778 to eeddcee Compare May 9, 2024 15:57
@AshCorr AshCorr marked this pull request as ready for review May 9, 2024 16:55
@AshCorr AshCorr requested review from a team as code owners May 9, 2024 16:55
Copy link
Member

@akash1810 akash1810 left a comment

Choose a reason for hiding this comment

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

Looks great. Shall we walk @guardian/devx-security and @guardian/devx-reliability through these changes? And plan how to migrate any current obligations to this framework?

packages/obligatron/src/obligations/tagging.ts Outdated Show resolved Hide resolved
packages/cdk/lib/obligatron.ts Show resolved Hide resolved
packages/obligatron/src/obligations/tagging.ts Outdated Show resolved Hide resolved
Copy link
Member

@akash1810 akash1810 left a comment

Choose a reason for hiding this comment

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

Couple of minor, non-blocking comments.

packages/obligatron/src/obligations/tagging.ts Outdated Show resolved Hide resolved
packages/obligatron/src/obligations/index.ts Show resolved Hide resolved

const REQUIRED_TAGS = ['Stack', 'Stage', 'App', 'gu:repo'] as const;

const isExemptResource = (resource: AwsResource): boolean => {
Copy link
Member

Choose a reason for hiding this comment

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

Not a blocker for this PR, I wonder if switching on the resource would make it easier to assert those rules that apply to specific resource? For example:

switch (resourceType): {
  case IAM_USER: {
    return evaluateStandardTags && evaluateIamUserTags;
  }
  case EC2_AMI: {
    return evaluateStandardTags && evaluateEc2AmiTags;
  }
  default: {
    return evaluateStandardTags;
  }
}

@AshCorr
Copy link
Member Author

AshCorr commented May 21, 2024

Going to merge this down as is as I want to get some code merged in and not keep updating this PR. There will likely be some changes once the ADR is published and theres a good chance we'll switch to pulling data from Security Hub instead of our AWS Resources view once we've finished figuring out how we turn that on for all accounts.

@AshCorr AshCorr enabled auto-merge May 21, 2024 09:02
@AshCorr AshCorr merged commit 2fbab24 into main May 21, 2024
2 checks passed
@AshCorr AshCorr deleted the mob/obligatron branch May 21, 2024 09:08
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.

None yet

3 participants