Skip to content

Commit

Permalink
feat: update CDK Version to the latest. 2.96.2 -> 2.162.0 (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
malcyL authored Oct 11, 2024
1 parent 3d32a4a commit fb0ee04
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 143 deletions.
4 changes: 2 additions & 2 deletions examples/container-lambda-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"devDependencies": {
"@types/jest": "^29.5.4",
"@types/node": "20.5.9",
"aws-cdk": "2.96.2",
"aws-cdk": "2.162.0",
"jest": "^29.6.4",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "~5.2.2"
},
"dependencies": {
"aws-cdk-lib": "2.96.2",
"aws-cdk-lib": "2.162.0",
"cdk-ecr-deployment": "^2.5.30",
"constructs": "^10.0.0",
"source-map-support": "^0.5.21"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as cdk from "aws-cdk-lib";
// import { aws_ec2 as ec2 } from "aws-cdk-lib";
import { aws_s3 as s3 } from "aws-cdk-lib";
import { aws_sns as sns } from "aws-cdk-lib";
import * as apigatewayv2_alpha from "@aws-cdk/aws-apigatewayv2-alpha";
import * as apigatewayv2 from "aws-cdk-lib/aws-apigatewayv2";
import { Construct } from "constructs";

import { AuthenticatedApi, AuthenticatedApiFunction } from "../../../lib";
Expand Down Expand Up @@ -152,28 +152,28 @@ export class SimpleAuthenticatedApiStack extends cdk.Stack {
{
name: "route1",
path: "/1/route1",
method: apigatewayv2_alpha.HttpMethod.GET,
method: apigatewayv2.HttpMethod.GET,
lambda: route1Handler,
requiredScope: "analytics:admin",
},
{
name: "route2",
path: "/1/route2",
method: apigatewayv2_alpha.HttpMethod.GET,
method: apigatewayv2.HttpMethod.GET,
lambda: route2Handler,
isPublic: true,
},
{
name: "route3",
path: "/1/route3/{id}",
method: apigatewayv2_alpha.HttpMethod.GET,
method: apigatewayv2.HttpMethod.GET,
lambda: route3Handler,
requiredScope: "analytics:admin",
},
{
name: "route4",
path: "/1/route4/{id}/route4",
method: apigatewayv2_alpha.HttpMethod.GET,
method: apigatewayv2.HttpMethod.GET,
lambda: route4Handler,
requiredScope: "analytics:admin",
},
Expand Down Expand Up @@ -208,7 +208,7 @@ export class SimpleAuthenticatedApiStack extends cdk.Stack {
name: "simple authenticated api docs",
baseUrl: `${documentationBucket.bucketWebsiteUrl}/api-documentation/index.html`,
path: "/api-documentation",
method: apigatewayv2_alpha.HttpMethod.GET,
method: apigatewayv2.HttpMethod.GET,
});

console.log(`Regional domain name: ${api.domainName.regionalDomainName}`);
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-authenticated-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"devDependencies": {
"@types/jest": "^29.5.4",
"@types/node": "20.5.9",
"aws-cdk": "2.96.2",
"aws-cdk": "2.162.0",
"jest": "^29.6.4",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "~5.2.2"
},
"dependencies": {
"aws-cdk-lib": "2.96.2",
"aws-cdk-lib": "2.162.0",
"constructs": "^10.0.0",
"esbuild": "^0.19.3",
"source-map-support": "^0.5.21",
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-cdn-site-hosting-construct/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"devDependencies": {
"@types/jest": "^29.5.4",
"@types/node": "20.5.9",
"aws-cdk": "2.96.2",
"aws-cdk": "2.162.0",
"jest": "^29.6.4",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "~5.2.2"
},
"dependencies": {
"aws-cdk-lib": "2.96.2",
"aws-cdk-lib": "2.162.0",
"constructs": "10.2.70",
"path": "^0.12.7",
"source-map-support": "^0.5.21"
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-lambda-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"devDependencies": {
"@types/jest": "^29.5.4",
"@types/node": "20.5.9",
"aws-cdk": "2.96.2",
"aws-cdk": "2.162.0",
"jest": "^29.6.4",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "~5.2.2"
},
"dependencies": {
"aws-cdk-lib": "2.96.2",
"aws-cdk-lib": "2.162.0",
"constructs": "^10.0.0",
"esbuild": "^0.19.3",
"source-map-support": "^0.5.21"
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-talis-cdk-stack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"@types/node": "20.5.9",
"jest": "^29.6.4",
"ts-jest": "^29.1.1",
"aws-cdk": "2.96.2",
"aws-cdk": "2.162.0",
"ts-node": "^10.9.1",
"typescript": "~5.2.2"
},
"dependencies": {
"aws-cdk-lib": "2.96.2",
"aws-cdk-lib": "2.162.0",
"constructs": "^10.0.0",
"source-map-support": "^0.5.21"
}
Expand Down
33 changes: 14 additions & 19 deletions lib/authenticated-api/authenticated-api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as cdk from "aws-cdk-lib";
import * as acm from "aws-cdk-lib/aws-certificatemanager";
import { aws_apigatewayv2 as apigatewayv2 } from "aws-cdk-lib";
import * as apigatewayv2_alpha from "@aws-cdk/aws-apigatewayv2-alpha";
import * as authorizers_alpha from "@aws-cdk/aws-apigatewayv2-authorizers-alpha";
import * as integrations_alpha from "@aws-cdk/aws-apigatewayv2-integrations-alpha";
import * as apigatewayv2 from "aws-cdk-lib/aws-apigatewayv2";
import * as authorizers from "aws-cdk-lib/aws-apigatewayv2-authorizers";
import * as integrations from "aws-cdk-lib/aws-apigatewayv2-integrations";
import { aws_cloudwatch as cloudwatch } from "aws-cdk-lib";
import { aws_cloudwatch_actions as cloudwatchActions } from "aws-cdk-lib";
import { aws_logs as awslogs } from "aws-cdk-lib";
Expand All @@ -22,10 +21,10 @@ const DEFAULT_LAMBDA_DURATION_THRESHOLD = cdk.Duration.minutes(1);
export class AuthenticatedApi extends Construct {
readonly apiId: string;
readonly httpApiId: string;
readonly domainName: apigatewayv2_alpha.DomainName;
readonly domainName: apigatewayv2.DomainName;

private httpApi: apigatewayv2_alpha.HttpApi;
private authorizer: apigatewayv2_alpha.IHttpRouteAuthorizer;
private httpApi: apigatewayv2.HttpApi;
private authorizer: apigatewayv2.IHttpRouteAuthorizer;
private alarmAction: cloudwatch.IAlarmAction;

constructor(scope: Construct, id: string, props: AuthenticatedApiProps) {
Expand All @@ -39,7 +38,7 @@ export class AuthenticatedApi extends Construct {
`To use a custom domain name both certificateArn and domainName must be specified`,
);
}
this.domainName = new apigatewayv2_alpha.DomainName(this, "domain-name", {
this.domainName = new apigatewayv2.DomainName(this, "domain-name", {
domainName: props.domainName,
certificate: acm.Certificate.fromCertificateArn(
this,
Expand All @@ -48,24 +47,20 @@ export class AuthenticatedApi extends Construct {
),
});
const apiName = `${props.prefix}${props.name}`;
const apiGatewayProps: apigatewayv2_alpha.HttpApiProps = {
const apiGatewayProps: apigatewayv2.HttpApiProps = {
apiName: apiName,
defaultDomainMapping: { domainName: this.domainName },
...(props.corsDomain && {
corsPreflight: {
allowHeaders: ["*"],
allowMethods: [apigatewayv2_alpha.CorsHttpMethod.ANY],
allowMethods: [apigatewayv2.CorsHttpMethod.ANY],
allowCredentials: props.corsAllowCredentials ?? true,
allowOrigins: props.corsDomain,
},
}),
};

this.httpApi = new apigatewayv2_alpha.HttpApi(
this,
apiName,
apiGatewayProps,
);
this.httpApi = new apigatewayv2.HttpApi(this, apiName, apiGatewayProps);

this.apiId = this.httpApi.apiId;
this.httpApiId = this.httpApi.httpApiId;
Expand Down Expand Up @@ -178,12 +173,12 @@ export class AuthenticatedApi extends Construct {
},
);

this.authorizer = new authorizers_alpha.HttpLambdaAuthorizer(
this.authorizer = new authorizers.HttpLambdaAuthorizer(
"lambda-authorizer",
authLambda,
{
authorizerName: `${apiName}-http-lambda-authoriser`,
responseTypes: [authorizers_alpha.HttpLambdaResponseType.SIMPLE], // Define if returns simple and/or iam response
responseTypes: [authorizers.HttpLambdaResponseType.SIMPLE], // Define if returns simple and/or iam response
},
);

Expand All @@ -195,7 +190,7 @@ export class AuthenticatedApi extends Construct {

if (props.lambdaRoutes) {
for (const routeProps of props.lambdaRoutes) {
const integration = new integrations_alpha.HttpLambdaIntegration(
const integration = new integrations.HttpLambdaIntegration(
"http-lambda-integration",
routeProps.lambda,
);
Expand Down Expand Up @@ -309,7 +304,7 @@ export class AuthenticatedApi extends Construct {
this.httpApi.addRoutes({
path: routeProps.path,
methods: [routeProps.method],
integration: new integrations_alpha.HttpUrlIntegration(
integration: new integrations.HttpUrlIntegration(
routeProps.name,
routeProps.baseUrl,
{
Expand Down
4 changes: 2 additions & 2 deletions lib/authenticated-api/route-lambda-props.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as cdk from "aws-cdk-lib";
import * as apigatewayv2_alpha from "@aws-cdk/aws-apigatewayv2-alpha";
import * as apigatewayv2 from "aws-cdk-lib/aws-apigatewayv2";

import { AuthenticatedApiFunction } from "./authenticated-api-function";

export interface RouteLambdaProps {
name: string;
path: string;
method: apigatewayv2_alpha.HttpMethod;
method: apigatewayv2.HttpMethod;
isPublic?: boolean; // Defaults to false
requiredScope?: string;
lambda: AuthenticatedApiFunction;
Expand Down
4 changes: 2 additions & 2 deletions lib/authenticated-api/route-url-props.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as apigatewayv2_alpha from "@aws-cdk/aws-apigatewayv2-alpha";
import * as apigatewayv2 from "aws-cdk-lib/aws-apigatewayv2";

export interface RouteUrlProps {
name: string;
baseUrl: string;
path: string;
method: apigatewayv2_alpha.HttpMethod;
method: apigatewayv2.HttpMethod;
isPublic?: boolean; // Defaults to false
requiredScope?: string;
}
Loading

0 comments on commit fb0ee04

Please sign in to comment.