A JSII construct lib to build AWS Serverless LAMP with AWS CDK
Project description
Welcome to cdk-serverless-lamp
cdk-serverless-lamp
is a JSII construct library for AWS CDK that allows you to deploy the New Serverless LAMP Stack running PHP Laravel Apps by specifying the local laravel
directory.
By deploying this stack, it creates the following resources for you:
- Amazon API Gateway HTTP API
- AWS Lambda custom runtime with Bref runtime support
- Amazon Aurora for MySQL database cluster with RDS proxy enabled
Usage
Building your serverless Laravel with ServerlessLaravel
construct:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
from cdk_serverless_lamp import ServerlessLaravel
from aws_cdk.core import App, Stack
import path as path
app = App()
stack = Stack(app, "ServerlessLaraval")
# the DatabaseCluster sharing the same vpc with the ServerlessLaravel
db = DatabaseCluster(stack, "DatabaseCluster",
vpc=vpc,
instance_type=InstanceType("t3.small"),
rds_proxy=True
)
# the ServerlessLaravel
ServerlessLaravel(stack, "ServerlessLaravel",
bref_layer_version="arn:aws:lambda:ap-northeast-1:209497400698:layer:php-74-fpm:11",
laravel_path=path.join(__dirname, "../../codebase"),
vpc=vpc,
database_config={
"writer_endpoint": db.rds_proxy.endpoint
}
)
On deploy complete, the API Gateway URL will be returned in the Output. Click the URL and you will see the Laravel landing page:
Prepare the Laravel and bref
$ git clone https://github.com/pahud/cdk-serverless-lamp.git
$ cd cdk-serverless-lamp && mkdir codebase
# create a laravel project
$ docker run --rm -ti \
--volume $PWD:/app \
composer create-project --prefer-dist laravel/laravel ./codebase
# enter this project
cd codebase
# install bref in the vendor
$ docker run --rm -ti \
--volume $PWD:/app \
composer require bref/bref bref/laravel-bridge
(more information can be found in bref documentation)
what if you like to do some local develop ?
add follow to docker-compose.yml
version: "3.5"
services:
web:
image: bref/fpm-dev-gateway
ports:
- "8000:80"
volumes:
- ./laravel:/var/task
depends_on:
- php
environment:
HANDLER: public/index.php
php:
image: bref/php-74-fpm-dev
volumes:
- ./laravel:/var/task
and run this command docker-compose up -d
and now you can access http://localhost:8000.
(more information can be found in bref documentation)
Amazon RDS Cluster and Proxy
Use DatabaseCluster
construct to create your database clusters.
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
db = DatabaseCluster(stack, "DatabaseCluster",
vpc=vpc,
instance_type=InstanceType("t3.small"),
# enable rds proxy for this cluster
rds_proxy=True,
# one writer and one read replica
instance_capacity=2
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cdk-serverless-lamp-1.3.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0414c732a2d373f78962c9ff5bdd7ecb055f9328d71435e0132ad43f466e4586 |
|
MD5 | fe3300f25a2583bb7df8b4851cc3884d |
|
BLAKE2b-256 | dda3640a54c9512a52b12f6bbf36ea535aab1d89453367c5ed85814eb066f2be |
Hashes for cdk_serverless_lamp-1.3.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c8c0fd543af7f0570b5da4924b9c51a6f86e3bc1d93be6b2aee56ad32aab97a |
|
MD5 | 6f75e5546ea87e280d6933c55541cd42 |
|
BLAKE2b-256 | 6c20b33e2730eb6b99004b0af9f683d8921db9fa40b5ab9d0dd4e7d5d01c72bf |