Skip to content

Commit

Permalink
Add license checker and missing license headers
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <gaiksaya@amazon.com>
  • Loading branch information
gaiksaya committed Oct 29, 2024
1 parent 157464b commit b850b00
Show file tree
Hide file tree
Showing 116 changed files with 768 additions and 106 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/license-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: License Header Checker

on: [push, pull_request]

jobs:
license-header-checker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check License Header
run: npx @kt3k/license-checker

34 changes: 34 additions & 0 deletions .licenserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"**/*.*": [
" Copyright OpenSearch Contributors",
" SPDX-License-Identifier: Apache-2.0"
],
"ignore": [
".md",
".d.ts",
".js",
"cdk.out",
".svg",
".yml",
".yaml",
".npmignore",
".bat",
".json",
".txt",
".config",
"settings.gradle",
".git",
".whitesource",
".shellcheckrc",
".lock",
".gradle",
".cert",
".key",
".jar",
".gz",
".toml",
".ini",
"gradle/wrapper",
"node_modules"
]
}
12 changes: 11 additions & 1 deletion infrastructure/bin/infrastructure.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#!/usr/bin/env node
import 'source-map-support/register';

/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import * as cdk from 'aws-cdk-lib';
import 'source-map-support/register';
import { InfrastructureStack } from '../lib/infrastructure-stack';

const app = new cdk.App();
Expand Down
10 changes: 5 additions & 5 deletions infrastructure/lib/constructs/canarySns.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import { SnsMonitors } from "./snsMonitor";
import { SnsMonitorsProps } from "./snsMonitor";
import { Construct } from "constructs";
import { Duration } from "aws-cdk-lib";
import { Alarm, ComparisonOperator, TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
import { Canary } from 'aws-cdk-lib/aws-synthetics';
import { Duration } from "aws-cdk-lib";
import { Construct } from "constructs";
import { SnsMonitors, SnsMonitorsProps } from "./snsMonitor";

interface canarySnsProps extends SnsMonitorsProps {
readonly canaryAlarms: Array<{ alertName: string, canary: Canary }>;
Expand Down
3 changes: 2 additions & 1 deletion infrastructure/lib/constructs/lambda.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand Down
7 changes: 4 additions & 3 deletions infrastructure/lib/constructs/opensearchCognito.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand All @@ -7,9 +8,9 @@
*/

import { RemovalPolicy } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { Effect, FederatedPrincipal, ManagedPolicy, PolicyStatement, Role, ServicePrincipal } from "aws-cdk-lib/aws-iam";
import { CfnIdentityPool, CfnIdentityPoolRoleAttachment, CfnUserPool, CfnUserPoolClient, CfnUserPoolDomain, CfnUserPoolGroup } from 'aws-cdk-lib/aws-cognito';
import { Effect, FederatedPrincipal, ManagedPolicy, PolicyStatement, Role, ServicePrincipal } from "aws-cdk-lib/aws-iam";
import { Construct } from 'constructs';

export interface OpenSearchMetricsCognitoProps {
readonly openSearchDomainArn: string;
Expand Down
3 changes: 2 additions & 1 deletion infrastructure/lib/constructs/opensearchNginxProxyCognito.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand Down
3 changes: 2 additions & 1 deletion infrastructure/lib/constructs/snsMonitor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand Down
3 changes: 2 additions & 1 deletion infrastructure/lib/constructs/stepFunctionSns.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand Down
3 changes: 2 additions & 1 deletion infrastructure/lib/enums/project.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand Down
27 changes: 14 additions & 13 deletions infrastructure/lib/infrastructure-stack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand All @@ -7,22 +8,22 @@
*/

import { App, Fn, Stack, StackProps } from 'aws-cdk-lib';
import { ArnPrincipal } from "aws-cdk-lib/aws-iam";
import { Construct } from 'constructs';
import { VpcStack } from "./stacks/vpc";
import { OpenSearchDomainStack } from "./stacks/opensearch";
import { OpenSearchMetricsNginxCognito } from "./constructs/opensearchNginxProxyCognito";
import Project from './enums/project';
import { OpenSearchHealthRoute53 } from "./stacks/route53";
import { GitHubAutomationApp } from "./stacks/gitHubAutomationApp";
import { GitHubWorkflowMonitorAlarms } from "./stacks/gitHubWorkflowMonitorAlarms";
import { OpenSearchMetricsWorkflowStack } from "./stacks/metricsWorkflow";
import { OpenSearchMetricsNginxReadonly } from "./stacks/opensearchNginxProxyReadonly";
import { ArnPrincipal } from "aws-cdk-lib/aws-iam";
import { OpenSearchWAF } from "./stacks/waf";
import { OpenSearchMetricsNginxCognito } from "./constructs/opensearchNginxProxyCognito";
import { OpenSearchMetricsMonitoringStack } from "./stacks/monitoringDashboard";
import { OpenSearchMetricsSecretsStack } from "./stacks/secrets";
import { GitHubAutomationApp } from "./stacks/gitHubAutomationApp";
import { OpenSearchDomainStack } from "./stacks/opensearch";
import { OpenSearchMetricsNginxReadonly } from "./stacks/opensearchNginxProxyReadonly";
import { OpenSearchHealthRoute53 } from "./stacks/route53";
import { OpenSearchS3 } from "./stacks/s3";
import { GitHubWorkflowMonitorAlarms } from "./stacks/gitHubWorkflowMonitorAlarms";
import {OpenSearchS3EventIndexWorkflowStack} from "./stacks/s3EventIndexWorkflow";
import { OpenSearchS3EventIndexWorkflowStack } from "./stacks/s3EventIndexWorkflow";
import { OpenSearchMetricsSecretsStack } from "./stacks/secrets";
import { VpcStack } from "./stacks/vpc";
import { OpenSearchWAF } from "./stacks/waf";

export class InfrastructureStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
Expand All @@ -39,7 +40,7 @@ export class InfrastructureStack extends Stack {
});


// Alarms to Monitor the Critical GitHub CI workflows by the GitHub Automation App
// Alarms to Monitor the Critical GitHub CI workflows by the GitHub Automation App
const gitHubWorkflowMonitorAlarms = new GitHubWorkflowMonitorAlarms(app, "OpenSearchMetrics-GitHubWorkflowMonitor-Alarms", {
namespace: 'GitHubActions',
metricName: 'WorkflowRunFailures',
Expand Down
9 changes: 5 additions & 4 deletions infrastructure/lib/stacks/gitHubAutomationApp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand Down Expand Up @@ -31,8 +32,8 @@ import {
Role,
ServicePrincipal
} from 'aws-cdk-lib/aws-iam';
import { Construct } from 'constructs';
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
import { Construct } from 'constructs';


export interface GitHubAppProps {
Expand All @@ -59,8 +60,8 @@ export class GitHubAutomationApp extends Stack {

this.asg = new AutoScalingGroup(this, 'OpenSearchMetrics-GitHubAutomationApp-Asg', {
instanceType: InstanceType.of(InstanceClass.M5, InstanceSize.XLARGE),
blockDevices: [{deviceName: '/dev/xvda', volume: BlockDeviceVolume.ebs(20)}],
healthCheck: HealthCheck.ec2({grace: Duration.seconds(90)}),
blockDevices: [{ deviceName: '/dev/xvda', volume: BlockDeviceVolume.ebs(20) }],
healthCheck: HealthCheck.ec2({ grace: Duration.seconds(90) }),
machineImage: props && props.ami ?
MachineImage.fromSsmParameter(props.ami) :
MachineImage.latestAmazonLinux2(),
Expand Down
11 changes: 6 additions & 5 deletions infrastructure/lib/stacks/gitHubWorkflowMonitorAlarms.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import {Duration, Stack} from "aws-cdk-lib";
import {Construct} from "constructs";
import {Alarm, ComparisonOperator, Metric, TreatMissingData} from "aws-cdk-lib/aws-cloudwatch";
import { Duration, Stack } from "aws-cdk-lib";
import { Alarm, ComparisonOperator, Metric } from "aws-cdk-lib/aws-cloudwatch";
import { Construct } from "constructs";

export interface AlarmProps {
readonly namespace: string;
Expand All @@ -33,7 +34,7 @@ export class GitHubWorkflowMonitorAlarms extends Stack {
statistic: 'Sum',
});

const alarm = new Alarm (this, `OpenSearchMetrics-GitHubApp-${dimensionValue.replace(/\s+/g, '')}-FailuresAlarm`, {
const alarm = new Alarm(this, `OpenSearchMetrics-GitHubApp-${dimensionValue.replace(/\s+/g, '')}-FailuresAlarm`, {
alarmName: `OpenSearchMetrics-GitHubApp-${dimensionValue.replace(/\s+/g, '')}-FailuresAlarm`,
metric: workflowMetric,
threshold: 2,
Expand Down
5 changes: 3 additions & 2 deletions infrastructure/lib/stacks/metricsWorkflow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand Down Expand Up @@ -53,7 +54,7 @@ export class OpenSearchMetricsWorkflowStack extends Stack {
}

private createMetricsTask(scope: Construct, opensearchDomainStack: OpenSearchDomainStack,
vpcStack: VpcStack, lambdaPackage: string) {
vpcStack: VpcStack, lambdaPackage: string) {
const openSearchDomain = opensearchDomainStack.domain;
const metricsLambda = new OpenSearchLambda(scope, "OpenSearchMetricsLambdaFunction", {
lambdaNameBase: "OpenSearchMetricsDashboards",
Expand Down
5 changes: 3 additions & 2 deletions infrastructure/lib/stacks/monitoringDashboard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand All @@ -22,7 +23,7 @@ import { VpcStack } from "./vpc";
interface OpenSearchMetricsMonitoringStackProps extends StackProps {
readonly region: string;
readonly account: string;
readonly workflowComponent: {[component: string]: string};
readonly workflowComponent: { [component: string]: string };
readonly lambdaPackage: string;
readonly secrets: Secret;
readonly vpcStack: VpcStack;
Expand Down
7 changes: 4 additions & 3 deletions infrastructure/lib/stacks/opensearch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand All @@ -9,13 +10,13 @@
import { RemovalPolicy, Stack } from "aws-cdk-lib";
import { ArnPrincipal, CfnServiceLinkedRole, CompositePrincipal, Effect, IPrincipal, IRole, ManagedPolicy, PolicyDocument, PolicyStatement, Role, ServicePrincipal } from "aws-cdk-lib/aws-iam";
import { Domain, EngineVersion } from "aws-cdk-lib/aws-opensearchservice";
import { Bucket } from "aws-cdk-lib/aws-s3";
import { Construct } from "constructs";
import { OpenSearchMetricsCognito } from "../constructs/opensearchCognito";
import { OpenSearchMetricsNginxCognito } from "../constructs/opensearchNginxProxyCognito";
import Project from "../enums/project";
import { OpenSearchHealthRoute53 } from "./route53";
import { VpcStack } from "./vpc";
import {Bucket} from "aws-cdk-lib/aws-s3";


export interface OpenSearchStackProps {
Expand Down Expand Up @@ -103,7 +104,7 @@ export class OpenSearchDomainStack extends Stack {
actions: ["s3:GetObject",
"s3:ListBucket"],
resources: [props.githubEventsBucket.bucketArn,
`${props.githubEventsBucket.bucketArn}/*`],
`${props.githubEventsBucket.bucketArn}/*`],
})
]
})
Expand Down
3 changes: 2 additions & 1 deletion infrastructure/lib/stacks/opensearchNginxProxyReadonly.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand Down
7 changes: 4 additions & 3 deletions infrastructure/lib/stacks/route53.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand All @@ -7,9 +8,9 @@
*/

import { Stack } from "aws-cdk-lib";
import { Construct } from "constructs";
import { HostedZone } from "aws-cdk-lib/aws-route53";
import { Certificate, CertificateValidation } from "aws-cdk-lib/aws-certificatemanager";
import { HostedZone } from "aws-cdk-lib/aws-route53";
import { Construct } from "constructs";

export interface Route53Props {
readonly hostedZone: string,
Expand Down
7 changes: 4 additions & 3 deletions infrastructure/lib/stacks/s3.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import {Stack, RemovalPolicy, StackProps} from "aws-cdk-lib";
import { Bucket, BlockPublicAccess, BucketEncryption } from 'aws-cdk-lib/aws-s3';
import { RemovalPolicy, Stack, StackProps } from "aws-cdk-lib";
import { BlockPublicAccess, Bucket, BucketEncryption } from 'aws-cdk-lib/aws-s3';
import { Construct } from "constructs";

export class OpenSearchS3 extends Stack {
Expand Down
9 changes: 5 additions & 4 deletions infrastructure/lib/stacks/s3EventIndexWorkflow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand All @@ -7,15 +8,15 @@
*/

import { Duration, Stack, StackProps } from "aws-cdk-lib";
import {Rule, RuleTargetInput, Schedule} from "aws-cdk-lib/aws-events";
import { Rule, RuleTargetInput, Schedule } from "aws-cdk-lib/aws-events";
import { SfnStateMachine } from "aws-cdk-lib/aws-events-targets";
import {JsonPath, StateMachine, TaskInput} from "aws-cdk-lib/aws-stepfunctions";
import { Bucket } from "aws-cdk-lib/aws-s3";
import { JsonPath, StateMachine, TaskInput } from "aws-cdk-lib/aws-stepfunctions";
import { LambdaInvoke } from "aws-cdk-lib/aws-stepfunctions-tasks";
import { Construct } from 'constructs';
import { OpenSearchLambda } from "../constructs/lambda";
import { OpenSearchDomainStack } from "./opensearch";
import { VpcStack } from "./vpc";
import {Bucket} from "aws-cdk-lib/aws-s3";

export interface OpenSearchS3EventIndexWorkflowStackProps extends StackProps {
readonly region: string;
Expand Down
3 changes: 2 additions & 1 deletion infrastructure/lib/stacks/secrets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
Expand Down
Loading

0 comments on commit b850b00

Please sign in to comment.