diff --git a/.projen/deps.json b/.projen/deps.json index 739a20a..0bd6513 100644 --- a/.projen/deps.json +++ b/.projen/deps.json @@ -21,7 +21,7 @@ }, { "name": "aws-cdk-lib", - "version": "2.18.0", + "version": "2.29.1", "type": "build" }, { @@ -99,9 +99,13 @@ "name": "typescript", "type": "build" }, + { + "name": "@aws-cdk/aws-apigatewayv2-alpha", + "type": "peer" + }, { "name": "aws-cdk-lib", - "version": "^2.18.0", + "version": "^2.29.1", "type": "peer" }, { diff --git a/.projenrc.js b/.projenrc.js index f139df9..7febf8a 100644 --- a/.projenrc.js +++ b/.projenrc.js @@ -7,7 +7,7 @@ const project = new awscdk.AwsCdkConstructLibrary({ authorName: 'Pahud Hsieh', authorEmail: 'hunhsieh@amazon.com', name: PROJECT_NAME, - cdkVersion: '2.18.0', + cdkVersion: '2.29.1', description: PROJECT_DESCRIPTION, repository: 'https://github.com/aws-samples/cdk-serverless-lamp.git', defaultReleaseBranch: 'main', @@ -21,6 +21,9 @@ const project = new awscdk.AwsCdkConstructLibrary({ '@aws-cdk/aws-apigatewayv2-integrations-alpha', '@aws-cdk/aws-apigatewayv2-alpha', ], + peerDeps: [ + '@aws-cdk/aws-apigatewayv2-alpha', + ], autoApproveOptions: { secret: 'GITHUB_TOKEN', allowedUsernames: ['pahud'], diff --git a/API.md b/API.md index cd5e68f..8fc2fa0 100644 --- a/API.md +++ b/API.md @@ -93,6 +93,7 @@ new ServerlessApi(scope: Construct, id: string, props: ServerlessApiProps) Name | Type | Description -----|------|------------- +**endpoint** | [HttpApi](#aws-cdk-aws-apigatewayv2-alpha-httpapi) | **handler** | [aws_lambda.IFunction](#aws-cdk-lib-aws-lambda-ifunction) | **vpc**? | [aws_ec2.IVpc](#aws-cdk-lib-aws-ec2-ivpc) | __*Optional*__ @@ -127,6 +128,14 @@ new ServerlessLaravel(scope: Construct, id: string, props: ServerlessLaravelProp +### Properties + + +Name | Type | Description +-----|------|------------- +**api** | [ServerlessApi](#cdk-serverless-lamp-serverlessapi) | + + ## struct DatabaseConfig diff --git a/package.json b/package.json index 9464808..7d38262 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@types/node": "^14", "@typescript-eslint/eslint-plugin": "^5", "@typescript-eslint/parser": "^5", - "aws-cdk-lib": "2.18.0", + "aws-cdk-lib": "2.29.1", "constructs": "10.0.5", "eslint": "^8", "eslint-import-resolver-node": "^0.3.6", @@ -65,7 +65,8 @@ "typescript": "^4.7.4" }, "peerDependencies": { - "aws-cdk-lib": "^2.18.0", + "@aws-cdk/aws-apigatewayv2-alpha": "^2.29.1-alpha.0", + "aws-cdk-lib": "^2.29.1", "constructs": "^10.0.5" }, "dependencies": { diff --git a/src/index.ts b/src/index.ts index 25ffb0d..7b97f48 100644 --- a/src/index.ts +++ b/src/index.ts @@ -85,6 +85,7 @@ export interface ServerlessApiProps { export class ServerlessApi extends Construct { readonly handler: lambda.IFunction; readonly vpc?: ec2.IVpc; + readonly endpoint: apigateway.HttpApi; constructor(scope: Construct, id: string, props: ServerlessApiProps) { super(scope, id); @@ -119,7 +120,7 @@ export class ServerlessApi extends Construct { })); } - const endpoint = new apigateway.HttpApi(this, 'apiservice', { + const endpoint = this.endpoint = new apigateway.HttpApi(this, 'apiservice', { defaultIntegration: new HttpLambdaIntegration('lambdaHandler', this.handler), }); new CfnOutput(this, 'EndpointURL', { value: endpoint.url! }); @@ -141,9 +142,11 @@ export interface ServerlessLaravelProps extends ServerlessApiProps { * Use `ServerlessLaravel` to create the serverless Laravel resource */ export class ServerlessLaravel extends Construct { + readonly api:ServerlessApi; + constructor(scope: Construct, id: string, props: ServerlessLaravelProps) { super(scope, id); - new ServerlessApi(this, id, { + this.api = new ServerlessApi(this, id, { lambdaCodePath: props.laravelPath, brefLayerVersion: props.brefLayerVersion, handler: props.handler, diff --git a/yarn.lock b/yarn.lock index 07e065b..44ed022 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1176,19 +1176,19 @@ at-least-node@^1.0.0: resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2" integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== -aws-cdk-lib@2.18.0: - version "2.18.0" - resolved "https://registry.yarnpkg.com/aws-cdk-lib/-/aws-cdk-lib-2.18.0.tgz#a130edf9d90ec166d5c0f14d275ab49cbbe75261" - integrity sha512-4XpEqRgKSzDmcpeNGRqRlnWEltnt5+NoHWKpQDHUsAmyJ2QNQ5dYxVLIReaGiE9H8zS0rlpp3exuDEy0UgKj2Q== +aws-cdk-lib@2.29.1: + version "2.29.1" + resolved "https://registry.yarnpkg.com/aws-cdk-lib/-/aws-cdk-lib-2.29.1.tgz#3a7bfb03f988c37c9ccd7db454bd66ffce427d14" + integrity sha512-tmWhsmSvNrJD9/SFAD0The7hON3VYUcFchKnjPg4vwvY89XzZv76IB24KLy3XoXF33WYvCUzDQPO/bCZQBF4LA== dependencies: "@balena/dockerignore" "^1.0.2" case "1.6.3" fs-extra "^9.1.0" ignore "^5.2.0" - jsonschema "^1.4.0" + jsonschema "^1.4.1" minimatch "^3.1.2" punycode "^2.1.1" - semver "^7.3.5" + semver "^7.3.7" yaml "1.10.2" babel-jest@^27.5.1: @@ -3932,7 +3932,7 @@ jsonparse@^1.2.0, jsonparse@^1.3.1: resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg== -jsonschema@^1.4.0: +jsonschema@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.4.1.tgz#cc4c3f0077fb4542982973d8a083b6b34f482dab" integrity sha512-S6cATIPVv1z0IlxdN+zUk5EPjkGCdnhN4wVSBlvoUO1tOLJootbo9CquNJmbIh4yikWHiUedhRYrNPn1arpEmQ==