Skip to content

Commit 50f7a96

Browse files
committed
chore: update AWS CDK dependencies and refactor API integration
- Upgraded `aws-cdk-lib` to version `^2.190.0` in both `package.json` and `package-lock.json`. - Removed deprecated `@aws-cdk/aws-apigatewayv2-alpha` and `@aws-cdk/aws-apigatewayv2-integrations-alpha` dependencies. - Refactored API integration code to use the new `aws_apigatewayv2` and `aws_apigatewayv2_integrations` modules. - Updated domain name handling in API constructs to align with new imports.
1 parent 9907003 commit 50f7a96

File tree

5 files changed

+163
-152
lines changed

5 files changed

+163
-152
lines changed

Diff for: lib/stac-api/index.ts

+27-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {
22
Stack,
3+
aws_apigatewayv2 as apigatewayv2,
4+
aws_apigatewayv2_integrations as apigatewayv2_integrations,
35
aws_ec2 as ec2,
46
aws_rds as rds,
57
aws_lambda as lambda,
@@ -8,13 +10,6 @@ import {
810
Duration,
911
aws_logs,
1012
} from "aws-cdk-lib";
11-
import {
12-
IDomainName,
13-
HttpApi,
14-
ParameterMapping,
15-
MappingValue,
16-
} from "@aws-cdk/aws-apigatewayv2-alpha";
17-
import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-alpha";
1813
import { Construct } from "constructs";
1914
import { CustomLambdaFunctionProps } from "../utils";
2015
import * as path from "path";
@@ -106,25 +101,32 @@ export class PgStacApiLambda extends Construct {
106101
);
107102
}
108103

109-
const stacApi = new HttpApi(this, `${Stack.of(this).stackName}-stac-api`, {
110-
defaultDomainMapping: props.stacApiDomainName
111-
? {
112-
domainName: props.stacApiDomainName,
113-
}
114-
: undefined,
115-
defaultIntegration: new HttpLambdaIntegration(
116-
"integration",
117-
this.stacApiLambdaFunction,
118-
props.stacApiDomainName
104+
const stacApi = new apigatewayv2.HttpApi(
105+
this,
106+
`${Stack.of(this).stackName}-stac-api`,
107+
{
108+
defaultDomainMapping: props.stacApiDomainName
119109
? {
120-
parameterMapping: new ParameterMapping().overwriteHeader(
121-
"host",
122-
MappingValue.custom(props.stacApiDomainName.name)
123-
),
110+
domainName: props.stacApiDomainName,
124111
}
125-
: undefined
126-
),
127-
});
112+
: undefined,
113+
defaultIntegration: new apigatewayv2_integrations.HttpLambdaIntegration(
114+
"integration",
115+
this.stacApiLambdaFunction,
116+
props.stacApiDomainName
117+
? {
118+
parameterMapping:
119+
new apigatewayv2.ParameterMapping().overwriteHeader(
120+
"host",
121+
apigatewayv2.MappingValue.custom(
122+
props.stacApiDomainName.name
123+
)
124+
),
125+
}
126+
: undefined
127+
),
128+
}
129+
);
128130

129131
this.url = stacApi.url!;
130132

@@ -164,7 +166,7 @@ export interface PgStacApiLambdaProps {
164166
/**
165167
* Custom Domain Name Options for STAC API,
166168
*/
167-
readonly stacApiDomainName?: IDomainName;
169+
readonly stacApiDomainName?: apigatewayv2.IDomainName;
168170

169171
/**
170172
* List of STAC API extensions to enable.

Diff for: lib/tipg-api/index.ts

+30-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {
22
Stack,
3+
aws_apigatewayv2 as apigatewayv2,
4+
aws_apigatewayv2_integrations as apigatewayv2_integrations,
35
aws_ec2 as ec2,
46
aws_lambda as lambda,
57
aws_logs as logs,
@@ -8,8 +10,6 @@ import {
810
CfnOutput,
911
Duration,
1012
} from "aws-cdk-lib";
11-
import { IDomainName, HttpApi, ParameterMapping, MappingValue} from "@aws-cdk/aws-apigatewayv2-alpha";
12-
import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-alpha";
1313
import { Construct } from "constructs";
1414
import { CustomLambdaFunctionProps } from "../utils";
1515
import * as path from 'path';
@@ -51,18 +51,33 @@ import * as path from 'path';
5151
this.tiPgLambdaFunction.connections.allowTo(props.db, ec2.Port.tcp(5432), "allow connections from tipg");
5252
}
5353

54-
const tipgApi = new HttpApi(this, `${Stack.of(this).stackName}-tipg-api`, {
55-
defaultDomainMapping: props.tipgApiDomainName ? {
56-
domainName: props.tipgApiDomainName
57-
} : undefined,
58-
defaultIntegration: new HttpLambdaIntegration(
59-
"integration",
60-
this.tiPgLambdaFunction,
61-
props.tipgApiDomainName ? {
62-
parameterMapping: new ParameterMapping().overwriteHeader('host', MappingValue.custom(props.tipgApiDomainName.name))
63-
} : undefined
64-
),
65-
});
54+
const tipgApi = new apigatewayv2.HttpApi(
55+
this,
56+
`${Stack.of(this).stackName}-tipg-api`,
57+
{
58+
defaultDomainMapping: props.tipgApiDomainName
59+
? {
60+
domainName: props.tipgApiDomainName,
61+
}
62+
: undefined,
63+
defaultIntegration:
64+
new apigatewayv2_integrations.HttpLambdaIntegration(
65+
"integration",
66+
this.tiPgLambdaFunction,
67+
props.tipgApiDomainName
68+
? {
69+
parameterMapping:
70+
new apigatewayv2.ParameterMapping().overwriteHeader(
71+
"host",
72+
apigatewayv2.MappingValue.custom(
73+
props.tipgApiDomainName.name
74+
)
75+
),
76+
}
77+
: undefined
78+
),
79+
}
80+
);
6681

6782
this.url = tipgApi.url!;
6883

@@ -74,7 +89,6 @@ import * as path from 'path';
7489
}
7590

7691
export interface TiPgApiLambdaProps {
77-
7892
/**
7993
* VPC into which the lambda should be deployed.
8094
*/
@@ -106,8 +120,7 @@ import * as path from 'path';
106120
*
107121
* @default - undefined
108122
*/
109-
readonly tipgApiDomainName?: IDomainName;
110-
123+
readonly tipgApiDomainName?: apigatewayv2.IDomainName;
111124

112125
/**
113126
* Can be used to override the default lambda function properties.

Diff for: lib/titiler-pgstac-api/index.ts

+31-18
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import {
22
Stack,
3+
aws_apigatewayv2 as apigatewayv2,
4+
aws_apigatewayv2_integrations as apigatewayv2_integrations,
35
aws_iam as iam,
46
aws_ec2 as ec2,
57
aws_rds as rds,
68
aws_lambda as lambda,
79
aws_secretsmanager as secretsmanager,
810
CfnOutput,
911
Duration,
10-
aws_logs
12+
aws_logs,
1113
} from "aws-cdk-lib";
12-
import { IDomainName, HttpApi, ParameterMapping, MappingValue} from "@aws-cdk/aws-apigatewayv2-alpha";
13-
import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-alpha";
1414
import { Construct } from "constructs";
1515
import { CustomLambdaFunctionProps } from "../utils";
1616
import * as path from 'path';
@@ -74,18 +74,33 @@ import * as path from 'path';
7474
this.titilerPgstacLambdaFunction.connections.allowTo(props.db, ec2.Port.tcp(5432), "allow connections from titiler");
7575
}
7676

77-
const stacApi = new HttpApi(this, `${Stack.of(this).stackName}-titiler-pgstac-api`, {
78-
defaultDomainMapping: props.titilerPgstacApiDomainName ? {
79-
domainName: props.titilerPgstacApiDomainName
80-
} : undefined,
81-
defaultIntegration: new HttpLambdaIntegration(
82-
"integration",
83-
this.titilerPgstacLambdaFunction,
84-
props.titilerPgstacApiDomainName ? {
85-
parameterMapping: new ParameterMapping().overwriteHeader('host', MappingValue.custom(props.titilerPgstacApiDomainName.name))
86-
} : undefined
87-
),
88-
});
77+
const stacApi = new apigatewayv2.HttpApi(
78+
this,
79+
`${Stack.of(this).stackName}-titiler-pgstac-api`,
80+
{
81+
defaultDomainMapping: props.titilerPgstacApiDomainName
82+
? {
83+
domainName: props.titilerPgstacApiDomainName,
84+
}
85+
: undefined,
86+
defaultIntegration:
87+
new apigatewayv2_integrations.HttpLambdaIntegration(
88+
"integration",
89+
this.titilerPgstacLambdaFunction,
90+
props.titilerPgstacApiDomainName
91+
? {
92+
parameterMapping:
93+
new apigatewayv2.ParameterMapping().overwriteHeader(
94+
"host",
95+
apigatewayv2.MappingValue.custom(
96+
props.titilerPgstacApiDomainName.name
97+
)
98+
),
99+
}
100+
: undefined
101+
),
102+
}
103+
);
89104

90105
this.url = stacApi.url!;
91106

@@ -97,7 +112,6 @@ import * as path from 'path';
97112
}
98113

99114
export interface TitilerPgStacApiLambdaProps {
100-
101115
/**
102116
* VPC into which the lambda should be deployed.
103117
*/
@@ -134,13 +148,12 @@ import * as path from 'path';
134148
*
135149
* @default - undefined.
136150
*/
137-
readonly titilerPgstacApiDomainName?: IDomainName;
151+
readonly titilerPgstacApiDomainName?: apigatewayv2.IDomainName;
138152

139153
/**
140154
* Can be used to override the default lambda function properties.
141155
*
142156
* @default - defined in the construct.
143157
*/
144158
readonly lambdaFunctionOptions?: CustomLambdaFunctionProps;
145-
146159
}

0 commit comments

Comments
 (0)