-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
performance benchmark rest api feature
Signed-off-by: Rishabh Singh <[email protected]>
- Loading branch information
1 parent
553461d
commit 571b70d
Showing
26 changed files
with
8,373 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.js | ||
!jest.config.js | ||
*.d.ts | ||
node_modules | ||
|
||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*.ts | ||
!*.d.ts | ||
|
||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Welcome to your CDK TypeScript project | ||
|
||
This is a blank project for CDK development with TypeScript. | ||
|
||
The `cdk.json` file tells the CDK Toolkit how to execute your app. | ||
|
||
## Useful commands | ||
|
||
* `npm run build` compile typescript to js | ||
* `npm run watch` watch for changes and compile | ||
* `npm run test` perform the jest unit tests | ||
* `npx cdk deploy` deploy this stack to your default AWS account/region | ||
* `npx cdk diff` compare deployed stack with current state | ||
* `npx cdk synth` emits the synthesized CloudFormation template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
import * as cdk from 'aws-cdk-lib'; | ||
import {BenchmarkRestApiStack} from "../lib/restApi"; | ||
import {Monitoring} from "../lib/monitoring"; | ||
|
||
const app = new cdk.App(); | ||
|
||
const infraStack = new BenchmarkRestApiStack(app, 'benchmark-control-plane-stack', { | ||
env: { | ||
region: 'us-east-1', | ||
account: process.env.CDK_DEFAULT_ACCOUNT | ||
}, | ||
}); | ||
|
||
const monitoringStack = new Monitoring(app, 'benchmark-cp-monitor-stack', { | ||
env: { | ||
region: 'us-east-1', | ||
account: process.env.CDK_DEFAULT_ACCOUNT | ||
}, | ||
restApi: infraStack.getRestApi(), | ||
lambdaFunctions: infraStack.lambdaObject.getLambdaFunctions() | ||
}); | ||
|
||
monitoringStack.addDependency(infraStack); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"vpc-provider:account=592316141094:filter.vpc-id=vpc-02a906fc9397a5315:region=us-east-1:returnAsymmetricSubnets=true": { | ||
"vpcId": "vpc-02a906fc9397a5315", | ||
"vpcCidrBlock": "10.0.0.0/16", | ||
"ownerAccountId": "592316141094", | ||
"availabilityZones": [], | ||
"subnetGroups": [ | ||
{ | ||
"name": "Private", | ||
"type": "Private", | ||
"subnets": [ | ||
{ | ||
"subnetId": "subnet-0b9cde4832325a6b2", | ||
"cidr": "10.0.128.0/20", | ||
"availabilityZone": "us-east-1a", | ||
"routeTableId": "rtb-0e8b7a98d83de2fdb" | ||
}, | ||
{ | ||
"subnetId": "subnet-0dc597bbb6b49e29b", | ||
"cidr": "10.0.144.0/20", | ||
"availabilityZone": "us-east-1b", | ||
"routeTableId": "rtb-0b0f742ef8ec97e29" | ||
}, | ||
{ | ||
"subnetId": "subnet-0a87255dd71c4ad54", | ||
"cidr": "10.0.160.0/20", | ||
"availabilityZone": "us-east-1c", | ||
"routeTableId": "rtb-08909766c711e4639" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Public", | ||
"type": "Public", | ||
"subnets": [ | ||
{ | ||
"subnetId": "subnet-0ec6c9182017831bc", | ||
"cidr": "10.0.0.0/20", | ||
"availabilityZone": "us-east-1a", | ||
"routeTableId": "rtb-089a05b2e5296f778" | ||
}, | ||
{ | ||
"subnetId": "subnet-0b884682c462c3586", | ||
"cidr": "10.0.16.0/20", | ||
"availabilityZone": "us-east-1b", | ||
"routeTableId": "rtb-089a05b2e5296f778" | ||
}, | ||
{ | ||
"subnetId": "subnet-06fca5eca7269f509", | ||
"cidr": "10.0.32.0/20", | ||
"availabilityZone": "us-east-1c", | ||
"routeTableId": "rtb-089a05b2e5296f778" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"availability-zones:account=592316141094:region=us-east-1": [ | ||
"us-east-1a", | ||
"us-east-1b", | ||
"us-east-1c", | ||
"us-east-1d", | ||
"us-east-1e", | ||
"us-east-1f" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"app": "npx ts-node --prefer-ts-exts bin/infra.ts", | ||
"watch": { | ||
"include": [ | ||
"**" | ||
], | ||
"exclude": [ | ||
"README.md", | ||
"cdk*.json", | ||
"**/*.d.ts", | ||
"**/*.js", | ||
"tsconfig.json", | ||
"package*.json", | ||
"yarn.lock", | ||
"node_modules", | ||
"test" | ||
] | ||
}, | ||
"context": { | ||
"@aws-cdk/aws-lambda:recognizeLayerVersion": true, | ||
"@aws-cdk/core:checkSecretUsage": true, | ||
"@aws-cdk/core:target-partitions": [ | ||
"aws", | ||
"aws-cn" | ||
], | ||
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, | ||
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, | ||
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true, | ||
"@aws-cdk/aws-iam:minimizePolicies": true, | ||
"@aws-cdk/core:validateSnapshotRemovalPolicy": true, | ||
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true, | ||
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true, | ||
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true, | ||
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true, | ||
"@aws-cdk/core:enablePartitionLiterals": true, | ||
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true, | ||
"@aws-cdk/aws-iam:standardizedServicePrincipals": true, | ||
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true, | ||
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true, | ||
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true, | ||
"@aws-cdk/aws-route53-patters:useCertificate": true, | ||
"@aws-cdk/customresources:installLatestAwsSdkDefault": false, | ||
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true, | ||
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true, | ||
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true, | ||
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true, | ||
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true, | ||
"@aws-cdk/aws-redshift:columnId": true, | ||
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true, | ||
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true, | ||
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true, | ||
"@aws-cdk/aws-kms:aliasNameRef": true, | ||
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true, | ||
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true, | ||
"@aws-cdk/aws-efs:denyAnonymousAccess": true, | ||
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true, | ||
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true, | ||
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true, | ||
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true, | ||
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true, | ||
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true, | ||
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true, | ||
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true, | ||
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
testEnvironment: 'node', | ||
roots: ['<rootDir>/test'], | ||
testMatch: ['**/*.test.ts'], | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest' | ||
} | ||
}; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
|
||
[dev-packages] | ||
|
||
[requires] | ||
python_version = "3.9" |
64 changes: 64 additions & 0 deletions
64
jenkins-control-plane/infra/lib/compute/benchmarkLambdaFunctions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import {Construct} from "constructs"; | ||
import {PythonFunction} from "@aws-cdk/aws-lambda-python-alpha"; | ||
import * as python from "@aws-cdk/aws-lambda-python-alpha"; | ||
import * as path from "node:path"; | ||
import {Runtime} from "aws-cdk-lib/aws-lambda"; | ||
import * as cdk from "aws-cdk-lib"; | ||
import {Secret} from "aws-cdk-lib/aws-secretsmanager"; | ||
|
||
export class BenchmarkLambdaFunctions{ | ||
public readonly benchmarkLambda: PythonFunction; | ||
public readonly customAuthorizerLambda: PythonFunction; | ||
private lambdaFunctions: PythonFunction[] = []; | ||
|
||
constructor(scope: Construct){ | ||
const benchmarkJobToken = new Secret(scope, 'benchmarkJobToken', { | ||
secretName: 'benchmark-job-token' | ||
}); | ||
|
||
const benchmarkEndpointJobToken = new Secret(scope, 'benchmarkEndpointJobToken', { | ||
secretName: 'benchmark-endpoint-job-token' | ||
}); | ||
|
||
const github_app_id = new Secret(scope, 'githubAppId', { | ||
secretName: 'app_id' | ||
}); | ||
const github_installation_id = new Secret(scope, 'githubInstallationId', { | ||
secretName: 'installation_id' | ||
}); | ||
const github_private_key = new Secret(scope, 'githubPrivateKey', { | ||
secretName: 'private_key' | ||
}); | ||
|
||
this.benchmarkLambda = new python.PythonFunction(scope, 'submitJenkinsJob', { | ||
functionName: 'submit-benchmark-run', | ||
entry: path.join(__dirname,'../lambda'), | ||
runtime: Runtime.PYTHON_3_10, | ||
index: 'submit_jenkins_job.py', | ||
handler: 'handler', | ||
timeout: cdk.Duration.seconds(300), | ||
}); | ||
benchmarkJobToken.grantRead(this.benchmarkLambda); | ||
benchmarkEndpointJobToken.grantRead(this.benchmarkLambda); | ||
this.lambdaFunctions.push(this.benchmarkLambda) | ||
|
||
this.customAuthorizerLambda = new python.PythonFunction(scope, 'authorizer-lambda', { | ||
functionName: 'custom-lambda-authorizer', | ||
entry: path.join(__dirname, '../lambda'), | ||
runtime: Runtime.PYTHON_3_10, | ||
index: 'custom_lambda_auth.py', | ||
handler: 'lambda_handler', | ||
timeout: cdk.Duration.seconds(300) | ||
}); | ||
|
||
github_app_id.grantRead(this.customAuthorizerLambda); | ||
github_installation_id.grantRead(this.customAuthorizerLambda); | ||
github_private_key.grantRead(this.customAuthorizerLambda); | ||
|
||
this.lambdaFunctions.push(this.customAuthorizerLambda) | ||
} | ||
|
||
public getLambdaFunctions(): PythonFunction[] { | ||
return this.lambdaFunctions | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
boto3 = "<=1.34.37" | ||
requests = "<=2.28.1" | ||
python-jenkins = "1.8.0" | ||
ghapi = "1.0.5" | ||
jwt = "1.3.1" | ||
pytest = "*" | ||
pytest-mock = "*" | ||
|
||
[dev-packages] |
Oops, something went wrong.