Skip to content

Instantly share code, notes, and snippets.

Created August 29, 2022 06:48
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
CDK code for serverless PHP with Lambda and
import { CfnOutput, Stack, StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as apigateway from "@aws-cdk/aws-apigatewayv2-alpha";
import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-alpha";
import * as cdk from "aws-cdk-lib";
export class CdkBrefStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const handler = new lambda.Function(this, "PhpRuntime", {
runtime: lambda.Runtime.PROVIDED_AL2,
handler: "public/index.php",
code: lambda.Code.fromAsset("./backend"),
memorySize: 1024,
layers: [
const api = new apigateway.HttpApi(this, "HttpApi");
const lambdaHandlerIntegration = new HttpLambdaIntegration(
path: "/",
methods: [apigateway.HttpMethod.GET],
integration: lambdaHandlerIntegration,
new CfnOutput(this, "Url", {
value: api.url!,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment