This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
forked from briancaffey/cdk-fargate-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
integ.laravel.ts
61 lines (53 loc) · 1.78 KB
/
integ.laravel.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import * as path from 'path';
import * as acm from '@aws-cdk/aws-certificatemanager';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as cdk from '@aws-cdk/core';
import { Laravel } from './laravel';
const app = new cdk.App();
const env = {
region: process.env.CDK_DEFAULT_REGION,
account: process.env.CDK_DEFAULT_ACCOUNT,
};
const stack = new cdk.Stack(app, 'demo-laravel', { env });
const certArn = stack.node.tryGetContext('ACM_CERT_ARN');
const cert = certArn ? acm.Certificate.fromCertificateArn(stack, 'Cert', certArn) : undefined;
const vpc = getOrCreateVpc(stack);
/**
* laravel-nginx-php-fpm
*/
new Laravel(stack, 'LaravelNginxDemo', {
vpc,
auroraServerless: true,
spot: true,
enableExecuteCommand: true,
code: path.join(__dirname, '../services/laravel-nginx-php-fpm'),
loadbalancer: cert ? { port: 443, certificate: [cert] } : { port: 80 },
efsFileSystem: {
vpc,
removalPolicy: cdk.RemovalPolicy.DESTROY,
},
});
/**
* laravel-bitnami
*/
new Laravel(stack, 'LaravelBitnamiDemo', {
vpc,
auroraServerless: true,
spot: true,
enableExecuteCommand: true,
code: path.join(__dirname, '../services/laravel-bitnami'),
containerPort: 3000,
loadbalancer: cert ? { port: 443, certificate: [cert] } : { port: 80 },
efsFileSystem: {
vpc,
removalPolicy: cdk.RemovalPolicy.DESTROY,
},
});
function getOrCreateVpc(scope: cdk.Construct): ec2.IVpc {
// use an existing vpc or create a new one
return scope.node.tryGetContext('use_default_vpc') === '1'
|| process.env.CDK_USE_DEFAULT_VPC === '1' ? ec2.Vpc.fromLookup(scope, 'Vpc', { isDefault: true }) :
scope.node.tryGetContext('use_vpc_id') ?
ec2.Vpc.fromLookup(scope, 'Vpc', { vpcId: scope.node.tryGetContext('use_vpc_id') }) :
new ec2.Vpc(scope, 'Vpc', { maxAzs: 3, natGateways: 1 });
}