From 5a633cd0ef28e95d47bb85b985d98ad88f069917 Mon Sep 17 00:00:00 2001 From: Viorel Tabara Date: Wed, 11 Sep 2024 22:35:38 -0700 Subject: [PATCH 1/5] Fix 'npm install' failure. - Packages bumped to the respective versions [1][2]. [1]:https://github.com/aws-samples/aws-cdk-examples/pull/911 [2]:https://github.com/aws-samples/aws-cdk-examples/pull/1064 --- typescript/rds/mysql/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/rds/mysql/package.json b/typescript/rds/mysql/package.json index 46d7af96f5..34cf8397f2 100644 --- a/typescript/rds/mysql/package.json +++ b/typescript/rds/mysql/package.json @@ -12,8 +12,8 @@ "devDependencies": { "@types/jest": "^26.0.10", "@types/node": "*", - "jest": "^26.4.2", - "ts-jest": "^26.2.0", + "jest": "29.6.4", + "ts-jest": "29.2.4", "ts-node": "^10.9.1", "aws-cdk": "*", "typescript": "~5.1.6" From 08daf856979ebaf571470c738ab3dfbbba2bedf2 Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Tue, 17 Sep 2024 08:27:57 -0500 Subject: [PATCH 2/5] Update packages --- typescript/rds/aurora/package.json | 16 ++++++++-------- typescript/rds/mysql/package.json | 16 ++++++++-------- typescript/rds/oracle/package.json | 16 ++++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/typescript/rds/aurora/package.json b/typescript/rds/aurora/package.json index 65f7bdbabb..a857a1ff31 100644 --- a/typescript/rds/aurora/package.json +++ b/typescript/rds/aurora/package.json @@ -10,17 +10,17 @@ "cdk": "cdk" }, "devDependencies": { - "@types/jest": "^26.0.10", + "@types/jest": "^29.5.13", "@types/node": "*", - "jest": "^26.4.2", + "jest": "^29.7.0", "aws-cdk": "*", - "ts-jest": "^26.2.0", - "ts-node": "^10.9.1", - "typescript": "~5.1.6" + "ts-jest": "^29.2.5", + "ts-node": "^10.9.2", + "typescript": "~5.6.2" }, "dependencies": { - "aws-cdk-lib": "^2.0.0", - "constructs": "^10.0.0", - "source-map-support": "^0.5.16" + "aws-cdk-lib": "^2.158.0", + "constructs": "^10.3.0", + "source-map-support": "^0.5.21" } } diff --git a/typescript/rds/mysql/package.json b/typescript/rds/mysql/package.json index 34cf8397f2..a36e0627a3 100644 --- a/typescript/rds/mysql/package.json +++ b/typescript/rds/mysql/package.json @@ -10,18 +10,18 @@ "cdk": "cdk" }, "devDependencies": { - "@types/jest": "^26.0.10", + "@types/jest": "^29.5.13", "@types/node": "*", - "jest": "29.6.4", - "ts-jest": "29.2.4", - "ts-node": "^10.9.1", + "jest": "29.7.0", + "ts-jest": "29.2.5", + "ts-node": "^10.9.2", "aws-cdk": "*", - "typescript": "~5.1.6" + "typescript": "~5.6.2" }, "esModuleInterop": true, "dependencies": { - "aws-cdk-lib": "^2.0.0", - "constructs": "^10.0.0", - "source-map-support": "^0.5.16" + "aws-cdk-lib": "^2.158.0", + "constructs": "^10.3.0", + "source-map-support": "^0.5.21" } } \ No newline at end of file diff --git a/typescript/rds/oracle/package.json b/typescript/rds/oracle/package.json index 4dd3f29b95..332e905643 100644 --- a/typescript/rds/oracle/package.json +++ b/typescript/rds/oracle/package.json @@ -10,17 +10,17 @@ "cdk": "cdk" }, "devDependencies": { - "@types/jest": "^26.0.10", + "@types/jest": "^29.5.13", "@types/node": "*", - "jest": "^26.4.2", + "jest": "^29.7.0", "aws-cdk": "*", - "ts-jest": "^26.2.0", - "ts-node": "^10.9.1", - "typescript": "~5.1.6" + "ts-jest": "^29.2.5", + "ts-node": "^10.9.2", + "typescript": "~5.6.2" }, "dependencies": { - "aws-cdk-lib": "^2.0.0", - "constructs": "^10.0.0", - "source-map-support": "^0.5.16" + "aws-cdk-lib": "^2.158.0", + "constructs": "^10.3.0", + "source-map-support": "^0.5.21" } } From 2de5982157e1555b7e47da6766964ae32d75ff14 Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Tue, 24 Sep 2024 17:11:40 -0500 Subject: [PATCH 3/5] Chore: Follow best practices for ts var > let --- .../lib/lambdas/authorizer/index.ts | 4 ++-- typescript/lambda-api-ci/src/handler.ts | 4 ++-- .../neptune-with-vpc/neptune-with-vpc-stack.ts | 6 +++--- typescript/rds/aurora/aurora.ts | 2 +- typescript/rds/mysql/mysql.ts | 6 +++--- typescript/rds/oracle/oracle.ts | 6 +++--- typescript/waf/waf-cloudfront.ts | 14 +++++++------- typescript/waf/waf-regional.ts | 12 ++++++------ 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/typescript/api-gateway-lambda-token-authorizer/lib/lambdas/authorizer/index.ts b/typescript/api-gateway-lambda-token-authorizer/lib/lambdas/authorizer/index.ts index 85d00c3adf..6d709c6c5a 100644 --- a/typescript/api-gateway-lambda-token-authorizer/lib/lambdas/authorizer/index.ts +++ b/typescript/api-gateway-lambda-token-authorizer/lib/lambdas/authorizer/index.ts @@ -1,7 +1,7 @@ import { Context, APIGatewayTokenAuthorizerEvent, Callback } from "aws-lambda"; export const handler = function (event: APIGatewayTokenAuthorizerEvent, context: Context, callback: Callback) { - var token = event.authorizationToken; + let token = event.authorizationToken; switch (token) { case 'allow': callback(null, generatePolicy('user', 'Allow', event.methodArn)); @@ -17,7 +17,7 @@ export const handler = function (event: APIGatewayTokenAuthorizerEvent, context: } }; -var generatePolicy = function (principalId: string, effect: string, resource: string) { +let generatePolicy = function (principalId: string, effect: string, resource: string) { return { principalId: principalId, policyDocument: { diff --git a/typescript/lambda-api-ci/src/handler.ts b/typescript/lambda-api-ci/src/handler.ts index 88bd9393c9..54ecc458cf 100644 --- a/typescript/lambda-api-ci/src/handler.ts +++ b/typescript/lambda-api-ci/src/handler.ts @@ -7,12 +7,12 @@ const handler = async function (event: any, context: any) { const S3Client = new S3() try { - var method = event.httpMethod + let method = event.httpMethod if (method === "GET") { if (event.path === "/") { const data = await S3Client.listObjectsV2({ Bucket: bucketName }) - var body = { + let body = { widgets: data.Contents!.map(function (e) { return e.Key }), diff --git a/typescript/neptune-with-vpc/neptune-with-vpc-stack.ts b/typescript/neptune-with-vpc/neptune-with-vpc-stack.ts index 6971d3a5ee..7313d20ef4 100644 --- a/typescript/neptune-with-vpc/neptune-with-vpc-stack.ts +++ b/typescript/neptune-with-vpc/neptune-with-vpc-stack.ts @@ -41,9 +41,9 @@ export class NeptuneWithVpcStack extends cdk.Stack { }); // Get lists of Subnets by type - var neptunePublicSubnets = neptuneVpc.publicSubnets; - var neptunePrivateSubnets = neptuneVpc.privateSubnets; - var neptuneIsolatedSubnets = neptuneVpc.isolatedSubnets; + let neptunePublicSubnets = neptuneVpc.publicSubnets; + let neptunePrivateSubnets = neptuneVpc.privateSubnets; + let neptuneIsolatedSubnets = neptuneVpc.isolatedSubnets; // Create Subnet group list to be used with Neptune. const neptuneSubnets: ec2.SubnetSelection = { subnets: neptuneIsolatedSubnets }; diff --git a/typescript/rds/aurora/aurora.ts b/typescript/rds/aurora/aurora.ts index dc465827ec..9fab0d4ae3 100644 --- a/typescript/rds/aurora/aurora.ts +++ b/typescript/rds/aurora/aurora.ts @@ -144,7 +144,7 @@ export class Aurora extends Stack { let replicaInstances = props.replicaInstances ?? 1; let backupRetentionDays = props.backupRetentionDays ?? 14; - var ingressSources = []; + let ingressSources = []; if (typeof props.ingressSources !== 'undefined') { ingressSources = props.ingressSources; } diff --git a/typescript/rds/mysql/mysql.ts b/typescript/rds/mysql/mysql.ts index 2a92a904a7..01a0369a1f 100644 --- a/typescript/rds/mysql/mysql.ts +++ b/typescript/rds/mysql/mysql.ts @@ -103,15 +103,15 @@ export class Mysql extends Stack { super(scope, id); // default database username - var mysqlUsername = "dbadmin"; + let mysqlUsername = "dbadmin"; if (typeof props.mysqlUsername !== 'undefined') { mysqlUsername = props.mysqlUsername; } - var ingressSources = []; + let ingressSources = []; if (typeof props.ingressSources !== 'undefined') { ingressSources = props.ingressSources; } - var engineVersion = rds.MysqlEngineVersion.VER_8_0_28; + let engineVersion = rds.MysqlEngineVersion.VER_8_0_28; if (typeof props.engineVersion !== 'undefined') { engineVersion = props.engineVersion; } diff --git a/typescript/rds/oracle/oracle.ts b/typescript/rds/oracle/oracle.ts index b09947b0ec..722882e12e 100644 --- a/typescript/rds/oracle/oracle.ts +++ b/typescript/rds/oracle/oracle.ts @@ -103,15 +103,15 @@ export class Oracle extends Stack { super(scope, id); // default database username - var oracleUsername = "dbadmin"; + let oracleUsername = "dbadmin"; if (typeof props.oracleUsername !== 'undefined') { oracleUsername = "dbadmin"; } - var ingressSources = []; + let ingressSources = []; if (typeof props.ingressSources !== 'undefined') { ingressSources = props.ingressSources; } - var engineVersion = rds.OracleEngineVersion.VER_19_0_0_0_2021_04_R1; + let engineVersion = rds.OracleEngineVersion.VER_19_0_0_0_2021_04_R1; if (typeof props.engineVersion !== 'undefined') { engineVersion = props.engineVersion; } diff --git a/typescript/waf/waf-cloudfront.ts b/typescript/waf/waf-cloudfront.ts index 51589f9b3b..6bb42f69ba 100644 --- a/typescript/waf/waf-cloudfront.ts +++ b/typescript/waf/waf-cloudfront.ts @@ -17,23 +17,23 @@ export class WafCloudFrontStack extends cdk.Stack { * Create output for use in WAF config */ protected makeRules(listOfRules: listOfRules[] = []) { - var rules: wafv2.CfnRuleGroup.RuleProperty[] = []; + let rules: wafv2.CfnRuleGroup.RuleProperty[] = []; listOfRules.forEach(function (r) { - var mrgsp: wafv2.CfnWebACL.ManagedRuleGroupStatementProperty = { + let mrgsp: wafv2.CfnWebACL.ManagedRuleGroupStatementProperty = { name: r['name'], vendorName: "AWS", excludedRules: [] }; - var stateProp: wafv2.CfnWebACL.StatementProperty = { + let stateProp: wafv2.CfnWebACL.StatementProperty = { managedRuleGroupStatement: { name: r['name'], vendorName: "AWS", } }; - var overrideAction: wafv2.CfnWebACL.OverrideActionProperty = { none: {} } + let overrideAction: wafv2.CfnWebACL.OverrideActionProperty = { none: {} } - var rule: wafv2.CfnWebACL.RuleProperty = { + let rule: wafv2.CfnWebACL.RuleProperty = { name: r['name'], priority: r['priority'], overrideAction: overrideAction, @@ -48,7 +48,7 @@ export class WafCloudFrontStack extends cdk.Stack { }); // forEach // Allowed country list - var ruleGeoMatch: wafv2.CfnWebACL.RuleProperty = { + let ruleGeoMatch: wafv2.CfnWebACL.RuleProperty = { name: 'GeoMatch', priority: 0, action: { @@ -95,7 +95,7 @@ export class WafCloudFrontStack extends cdk.Stack { * and requests will be blocked once this limit is reached. * The IP address is automatically unblocked after it falls below the limit. */ - var ruleLimitRequests100: wafv2.CfnWebACL.RuleProperty = { + let ruleLimitRequests100: wafv2.CfnWebACL.RuleProperty = { name: 'LimitRequests100', priority: 1, action: { diff --git a/typescript/waf/waf-regional.ts b/typescript/waf/waf-regional.ts index b3181b8901..56aa0ab4ec 100644 --- a/typescript/waf/waf-regional.ts +++ b/typescript/waf/waf-regional.ts @@ -17,18 +17,18 @@ export class WafRegionalStack extends cdk.Stack { * Create output for use in WAF config */ protected makeRules(listOfRules: listOfRules[] = []) { - var rules: wafv2.CfnRuleGroup.RuleProperty[] = []; + let rules: wafv2.CfnRuleGroup.RuleProperty[] = []; for (const r of listOfRules) { - var stateProp: wafv2.CfnWebACL.StatementProperty = { + let stateProp: wafv2.CfnWebACL.StatementProperty = { managedRuleGroupStatement: { name: r['name'], vendorName: "AWS", } }; - var overrideAction: wafv2.CfnWebACL.OverrideActionProperty = { none: {} } + let overrideAction: wafv2.CfnWebACL.OverrideActionProperty = { none: {} } - var rule: wafv2.CfnRuleGroup.RuleProperty = { + let rule: wafv2.CfnRuleGroup.RuleProperty = { name: r['name'], priority: r['priority'], // @ts-expect-error Property 'overrideAction' does not exist on type 'CfnRuleGroup.RuleProperty' @@ -44,7 +44,7 @@ export class WafRegionalStack extends cdk.Stack { }; // Allowed country list - var ruleGeoMatch: wafv2.CfnWebACL.RuleProperty = { + let ruleGeoMatch: wafv2.CfnWebACL.RuleProperty = { name: 'GeoMatch', priority: 0, action: { @@ -91,7 +91,7 @@ export class WafRegionalStack extends cdk.Stack { * and requests will be blocked once this limit is reached. * The IP address is automatically unblocked after it falls below the limit. */ - var ruleLimitRequests100: wafv2.CfnWebACL.RuleProperty = { + let ruleLimitRequests100: wafv2.CfnWebACL.RuleProperty = { name: 'LimitRequests100', priority: 1, action: { From f208a1f0111d70a5e1c02918b7920e107479dfbb Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Tue, 24 Sep 2024 17:22:42 -0500 Subject: [PATCH 4/5] Fix:up jest test --- .../__snapshots__/gateway-lambda-auth-stack.test.ts.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/api-gateway-lambda-token-authorizer/test/stack/__snapshots__/gateway-lambda-auth-stack.test.ts.snap b/typescript/api-gateway-lambda-token-authorizer/test/stack/__snapshots__/gateway-lambda-auth-stack.test.ts.snap index b9c251e70e..bfc243c6cf 100644 --- a/typescript/api-gateway-lambda-token-authorizer/test/stack/__snapshots__/gateway-lambda-auth-stack.test.ts.snap +++ b/typescript/api-gateway-lambda-token-authorizer/test/stack/__snapshots__/gateway-lambda-auth-stack.test.ts.snap @@ -190,7 +190,7 @@ exports[`Snapshot Stack 1`] = ` "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}", }, - "S3Key": "a89b0c25113046ece0e7fb82e6d729811e22e9ed30e0d44feb9ffa39ef67b8a4.zip", + "S3Key": "54d6cb98b9e5561fbb4fe0db67802db343f5d9cc99a208caf080d13cfcdb9d13.zip", }, "Description": "Lambda Authorizer", "Environment": { @@ -375,7 +375,7 @@ exports[`Snapshot Stack 1`] = ` "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}", }, - "S3Key": "5ce4b859d5e57c3d238da3ac017e0ea37bf34ad1b71de268430b08e38bb9450d.zip", + "S3Key": "7d88236a0e52bda80be5720fa18eb669103ca13ac2a446c41b0c83034981e124.zip", }, "Description": "Operational Lambda", "Environment": { From 55b0bcf854eead7d7011005e3191f52ec5b13d6c Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Tue, 24 Sep 2024 17:54:51 -0500 Subject: [PATCH 5/5] Fix:up jest test with hash that github expects --- .../__snapshots__/gateway-lambda-auth-stack.test.ts.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/api-gateway-lambda-token-authorizer/test/stack/__snapshots__/gateway-lambda-auth-stack.test.ts.snap b/typescript/api-gateway-lambda-token-authorizer/test/stack/__snapshots__/gateway-lambda-auth-stack.test.ts.snap index bfc243c6cf..df86865987 100644 --- a/typescript/api-gateway-lambda-token-authorizer/test/stack/__snapshots__/gateway-lambda-auth-stack.test.ts.snap +++ b/typescript/api-gateway-lambda-token-authorizer/test/stack/__snapshots__/gateway-lambda-auth-stack.test.ts.snap @@ -190,7 +190,7 @@ exports[`Snapshot Stack 1`] = ` "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}", }, - "S3Key": "54d6cb98b9e5561fbb4fe0db67802db343f5d9cc99a208caf080d13cfcdb9d13.zip", + "S3Key": "a1deff17a695906f93c544b1deae2bf444210622f05330da961687eb8f4a51a7.zip", }, "Description": "Lambda Authorizer", "Environment": { @@ -375,7 +375,7 @@ exports[`Snapshot Stack 1`] = ` "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}", }, - "S3Key": "7d88236a0e52bda80be5720fa18eb669103ca13ac2a446c41b0c83034981e124.zip", + "S3Key": "5ce4b859d5e57c3d238da3ac017e0ea37bf34ad1b71de268430b08e38bb9450d.zip", }, "Description": "Operational Lambda", "Environment": {