@mstuercke/pulumi-modules 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth0/Auth0.d.ts +29 -0
- package/dist/auth0/Auth0.js +81 -0
- package/dist/auth0/index.d.ts +5 -0
- package/dist/auth0/index.js +5 -0
- package/dist/domain/getDomain.d.ts +13 -0
- package/dist/domain/getDomain.js +14 -0
- package/dist/domain/index.d.ts +4 -0
- package/dist/domain/index.js +5 -0
- package/dist/iam/SimpleIamRolePolicy.d.ts +6 -0
- package/dist/iam/SimpleIamRolePolicy.js +115 -0
- package/dist/iam/SimpleIamRolePolicyConfig.d.ts +57 -0
- package/dist/iam/SimpleIamRolePolicyConfig.js +1 -0
- package/dist/iam/index.d.ts +6 -0
- package/dist/iam/index.js +6 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +29 -0
- package/dist/lambda/NodeLambdaFunction.d.ts +20 -0
- package/dist/lambda/NodeLambdaFunction.js +71 -0
- package/dist/lambda/WithInputs.d.ts +4 -0
- package/dist/lambda/WithInputs.js +1 -0
- package/dist/lambda/index.d.ts +5 -0
- package/dist/lambda/index.js +5 -0
- package/dist/mongodb/MongoDB.d.ts +13 -0
- package/dist/mongodb/MongoDB.js +51 -0
- package/dist/mongodb/MongoDBCustomInstance.d.ts +12 -0
- package/dist/mongodb/MongoDBCustomInstance.js +32 -0
- package/dist/mongodb/MongoDBDefaultInstance.d.ts +12 -0
- package/dist/mongodb/MongoDBDefaultInstance.js +19 -0
- package/dist/mongodb/MongoDBUser.d.ts +12 -0
- package/dist/mongodb/MongoDBUser.js +28 -0
- package/dist/mongodb/index.d.ts +11 -0
- package/dist/mongodb/index.js +11 -0
- package/dist/rest/RestApi.d.ts +19 -0
- package/dist/rest/RestApi.js +129 -0
- package/dist/rest/index.d.ts +5 -0
- package/dist/rest/index.js +5 -0
- package/dist/s3/PublicS3Bucket.d.ts +11 -0
- package/dist/s3/PublicS3Bucket.js +48 -0
- package/dist/s3/index.d.ts +5 -0
- package/dist/s3/index.js +5 -0
- package/dist/website/StaticWebsite.d.ts +17 -0
- package/dist/website/StaticWebsite.js +129 -0
- package/dist/website/index.d.ts +5 -0
- package/dist/website/index.js +5 -0
- package/dist/website/readFilesRecursive.d.ts +8 -0
- package/dist/website/readFilesRecursive.js +23 -0
- package/dist/websocket/WebsocketApi.d.ts +22 -0
- package/dist/websocket/WebsocketApi.js +130 -0
- package/dist/websocket/index.d.ts +5 -0
- package/dist/websocket/index.js +5 -0
- package/package.json +2 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type CustomResourceOptions, type Output, Resource } from '@pulumi/pulumi';
|
|
2
|
+
export type MongoDBDefaultInstanceArgs = {
|
|
3
|
+
organizationId: string;
|
|
4
|
+
projectId: string;
|
|
5
|
+
environmentName: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class MongoDBDefaultInstance extends Resource {
|
|
8
|
+
readonly mongoProjectId: Output<string>;
|
|
9
|
+
readonly connectionString: Output<string>;
|
|
10
|
+
readonly databaseName: string;
|
|
11
|
+
constructor(args: MongoDBDefaultInstanceArgs, opts?: CustomResourceOptions);
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { output, Resource } from '@pulumi/pulumi';
|
|
2
|
+
import { getProject, getServerlessInstance } from '@pulumi/mongodbatlas';
|
|
3
|
+
export class MongoDBDefaultInstance extends Resource {
|
|
4
|
+
mongoProjectId;
|
|
5
|
+
connectionString;
|
|
6
|
+
databaseName;
|
|
7
|
+
constructor(args, opts) {
|
|
8
|
+
const { organizationId, projectId, environmentName } = args;
|
|
9
|
+
super('mstuercke:mongodb:MongoDBDefaultInstance', organizationId, false, undefined, opts);
|
|
10
|
+
const mongoProject = output(getProject({ name: 'default' }));
|
|
11
|
+
const mongoInstance = mongoProject.id.apply((mongoProjectId) => output(getServerlessInstance({
|
|
12
|
+
projectId: mongoProjectId,
|
|
13
|
+
name: 'default',
|
|
14
|
+
})));
|
|
15
|
+
this.mongoProjectId = mongoProject.id;
|
|
16
|
+
this.connectionString = mongoInstance.connectionStringsStandardSrv;
|
|
17
|
+
this.databaseName = `${projectId}-${environmentName}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type CustomResourceOptions, type Input, type Output, Resource } from '@pulumi/pulumi';
|
|
2
|
+
export type MongoDBUserArgs = {
|
|
3
|
+
mongoProjectId: Input<string>;
|
|
4
|
+
databaseName: string;
|
|
5
|
+
projectId: string;
|
|
6
|
+
environmentName: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class MongoDBUser extends Resource {
|
|
9
|
+
readonly username: string;
|
|
10
|
+
readonly password: Output<string>;
|
|
11
|
+
constructor(args: MongoDBUserArgs, opts?: CustomResourceOptions);
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Resource } from '@pulumi/pulumi';
|
|
2
|
+
import { RandomPassword } from '@pulumi/random';
|
|
3
|
+
import { DatabaseUser } from '@pulumi/mongodbatlas';
|
|
4
|
+
export class MongoDBUser extends Resource {
|
|
5
|
+
username;
|
|
6
|
+
password;
|
|
7
|
+
constructor(args, opts) {
|
|
8
|
+
const { mongoProjectId, databaseName, projectId, environmentName } = args;
|
|
9
|
+
const username = `${projectId}-${environmentName}`;
|
|
10
|
+
super('mstuercke:mongodb:MongoDBUser', username, false, undefined, opts);
|
|
11
|
+
const password = new RandomPassword('password', {
|
|
12
|
+
length: 32,
|
|
13
|
+
special: false,
|
|
14
|
+
}, { parent: this });
|
|
15
|
+
new DatabaseUser('user', {
|
|
16
|
+
projectId: mongoProjectId,
|
|
17
|
+
username,
|
|
18
|
+
password: password.result,
|
|
19
|
+
authDatabaseName: 'admin',
|
|
20
|
+
roles: [
|
|
21
|
+
{ roleName: 'dbAdmin', databaseName },
|
|
22
|
+
{ roleName: 'readWrite', databaseName },
|
|
23
|
+
],
|
|
24
|
+
}, { parent: this });
|
|
25
|
+
this.username = username;
|
|
26
|
+
this.password = password.result;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MongoDBCustomInstance } from './MongoDBCustomInstance';
|
|
2
|
+
import { MongoDBDefaultInstance } from './MongoDBDefaultInstance';
|
|
3
|
+
import { MongoDBUser } from './MongoDBUser';
|
|
4
|
+
export * from './MongoDBCustomInstance';
|
|
5
|
+
export * from './MongoDBDefaultInstance';
|
|
6
|
+
export * from './MongoDBUser';
|
|
7
|
+
export declare const mongodb: {
|
|
8
|
+
MongoDBCustomInstance: typeof MongoDBCustomInstance;
|
|
9
|
+
MongoDBDefaultInstance: typeof MongoDBDefaultInstance;
|
|
10
|
+
MongoDBUser: typeof MongoDBUser;
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MongoDBCustomInstance } from './MongoDBCustomInstance';
|
|
2
|
+
import { MongoDBDefaultInstance } from './MongoDBDefaultInstance';
|
|
3
|
+
import { MongoDBUser } from './MongoDBUser';
|
|
4
|
+
export * from './MongoDBCustomInstance';
|
|
5
|
+
export * from './MongoDBDefaultInstance';
|
|
6
|
+
export * from './MongoDBUser';
|
|
7
|
+
export const mongodb = {
|
|
8
|
+
MongoDBCustomInstance,
|
|
9
|
+
MongoDBDefaultInstance,
|
|
10
|
+
MongoDBUser,
|
|
11
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as aws from '@pulumi/aws';
|
|
2
|
+
import type { CustomResourceOptions, Input } from '@pulumi/pulumi';
|
|
3
|
+
import type { NodeLambdaFunction } from '../lambda';
|
|
4
|
+
export interface RestApiArgs {
|
|
5
|
+
name: string;
|
|
6
|
+
projectId: string;
|
|
7
|
+
lambdaFunction: NodeLambdaFunction;
|
|
8
|
+
timeoutSeconds?: number;
|
|
9
|
+
stageName?: string;
|
|
10
|
+
domain: {
|
|
11
|
+
zoneId: Input<string>;
|
|
12
|
+
fullName: Input<string>;
|
|
13
|
+
usEast1CertificateArn: Input<string>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare class RestApi extends aws.apigateway.RestApi {
|
|
17
|
+
readonly url: string;
|
|
18
|
+
constructor(id: string, args: RestApiArgs, opts?: CustomResourceOptions);
|
|
19
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as aws from '@pulumi/aws';
|
|
2
|
+
import { apigateway, lambda } from '@pulumi/aws';
|
|
3
|
+
import { Record } from '@pulumi/aws/route53';
|
|
4
|
+
import { BasePathMapping, DomainName } from '@pulumi/aws/apigateway';
|
|
5
|
+
export class RestApi extends aws.apigateway.RestApi {
|
|
6
|
+
url;
|
|
7
|
+
constructor(id, args, opts) {
|
|
8
|
+
const { name, projectId, stageName = 'v1', domain } = args;
|
|
9
|
+
super(id, {
|
|
10
|
+
name,
|
|
11
|
+
tags: {
|
|
12
|
+
project: projectId,
|
|
13
|
+
},
|
|
14
|
+
}, opts);
|
|
15
|
+
const { lambdaFunction, timeoutSeconds = 29 } = args;
|
|
16
|
+
const proxyResource = new apigateway.Resource(`proxy`, {
|
|
17
|
+
restApi: this.id,
|
|
18
|
+
parentId: this.rootResourceId,
|
|
19
|
+
pathPart: '{proxy+}',
|
|
20
|
+
}, { parent: this });
|
|
21
|
+
const proxyMethod = new apigateway.Method(`proxy`, {
|
|
22
|
+
restApi: this.id,
|
|
23
|
+
resourceId: proxyResource.id,
|
|
24
|
+
httpMethod: 'ANY',
|
|
25
|
+
authorization: 'NONE',
|
|
26
|
+
}, { parent: proxyResource });
|
|
27
|
+
const lambdaIntegration = new apigateway.Integration(`proxy`, {
|
|
28
|
+
restApi: this.id,
|
|
29
|
+
resourceId: proxyResource.id,
|
|
30
|
+
httpMethod: proxyMethod.httpMethod,
|
|
31
|
+
integrationHttpMethod: 'POST',
|
|
32
|
+
type: 'AWS_PROXY',
|
|
33
|
+
uri: lambdaFunction.invokeArn,
|
|
34
|
+
timeoutMilliseconds: timeoutSeconds * 1000,
|
|
35
|
+
}, { parent: proxyMethod });
|
|
36
|
+
const proxyOptionsMethod = new apigateway.Method(`options`, {
|
|
37
|
+
restApi: this.id,
|
|
38
|
+
resourceId: proxyResource.id,
|
|
39
|
+
httpMethod: 'OPTIONS',
|
|
40
|
+
authorization: 'NONE',
|
|
41
|
+
}, { parent: proxyResource });
|
|
42
|
+
const lambdaIntegrationOptions = new apigateway.Integration(`options`, {
|
|
43
|
+
restApi: this.id,
|
|
44
|
+
resourceId: proxyResource.id,
|
|
45
|
+
httpMethod: proxyOptionsMethod.httpMethod,
|
|
46
|
+
integrationHttpMethod: 'POST',
|
|
47
|
+
type: 'AWS_PROXY',
|
|
48
|
+
uri: lambdaFunction.invokeArn,
|
|
49
|
+
timeoutMilliseconds: timeoutSeconds * 1000,
|
|
50
|
+
}, { parent: proxyOptionsMethod });
|
|
51
|
+
const proxyRootMethod = new apigateway.Method(`proxy-root`, {
|
|
52
|
+
restApi: this.id,
|
|
53
|
+
resourceId: this.rootResourceId,
|
|
54
|
+
httpMethod: 'ANY',
|
|
55
|
+
authorization: 'NONE',
|
|
56
|
+
}, { parent: this });
|
|
57
|
+
const lambdaRootIntegration = new apigateway.Integration(`proxy-root`, {
|
|
58
|
+
restApi: this.id,
|
|
59
|
+
resourceId: proxyRootMethod.resourceId,
|
|
60
|
+
httpMethod: proxyRootMethod.httpMethod,
|
|
61
|
+
integrationHttpMethod: 'POST',
|
|
62
|
+
type: 'AWS_PROXY',
|
|
63
|
+
uri: lambdaFunction.invokeArn,
|
|
64
|
+
timeoutMilliseconds: timeoutSeconds * 1000,
|
|
65
|
+
}, { parent: proxyRootMethod });
|
|
66
|
+
const proxyRootOptionsMethod = new apigateway.Method(`proxy-root-options`, {
|
|
67
|
+
restApi: this.id,
|
|
68
|
+
resourceId: this.rootResourceId,
|
|
69
|
+
httpMethod: 'OPTIONS',
|
|
70
|
+
authorization: 'NONE',
|
|
71
|
+
}, { parent: this });
|
|
72
|
+
const lambdaRootIntegrationOptions = new apigateway.Integration(`proxy-root-options`, {
|
|
73
|
+
restApi: this.id,
|
|
74
|
+
resourceId: proxyRootOptionsMethod.resourceId,
|
|
75
|
+
httpMethod: proxyRootOptionsMethod.httpMethod,
|
|
76
|
+
integrationHttpMethod: 'POST',
|
|
77
|
+
type: 'AWS_PROXY',
|
|
78
|
+
uri: lambdaFunction.invokeArn,
|
|
79
|
+
timeoutMilliseconds: timeoutSeconds * 1000,
|
|
80
|
+
}, { parent: proxyRootOptionsMethod });
|
|
81
|
+
new lambda.Permission(`rest-api`, {
|
|
82
|
+
statementId: 'AllowRestApiInvoke',
|
|
83
|
+
action: 'lambda:InvokeFunction',
|
|
84
|
+
function: lambdaFunction.name,
|
|
85
|
+
principal: 'apigateway.amazonaws.com',
|
|
86
|
+
sourceArn: this.executionArn.apply((executionArn) => `${executionArn}/*`),
|
|
87
|
+
}, { parent: lambdaFunction });
|
|
88
|
+
const deployment = new apigateway.Deployment(stageName, { restApi: this.id }, {
|
|
89
|
+
dependsOn: [
|
|
90
|
+
proxyMethod,
|
|
91
|
+
lambdaIntegration,
|
|
92
|
+
lambdaIntegrationOptions,
|
|
93
|
+
proxyRootMethod,
|
|
94
|
+
lambdaRootIntegration,
|
|
95
|
+
lambdaRootIntegrationOptions,
|
|
96
|
+
],
|
|
97
|
+
parent: this,
|
|
98
|
+
});
|
|
99
|
+
const stage = new apigateway.Stage(stageName, {
|
|
100
|
+
restApi: this.id,
|
|
101
|
+
stageName: stageName,
|
|
102
|
+
deployment: deployment.id,
|
|
103
|
+
tags: { project: projectId },
|
|
104
|
+
}, { parent: deployment });
|
|
105
|
+
const domainName = new DomainName('domain', {
|
|
106
|
+
domainName: domain.fullName,
|
|
107
|
+
certificateArn: domain.usEast1CertificateArn,
|
|
108
|
+
}, { parent: this });
|
|
109
|
+
new Record('redirect', {
|
|
110
|
+
zoneId: domain.zoneId,
|
|
111
|
+
name: domain.fullName,
|
|
112
|
+
type: 'A',
|
|
113
|
+
aliases: [
|
|
114
|
+
{
|
|
115
|
+
zoneId: domainName.cloudfrontZoneId,
|
|
116
|
+
name: domainName.cloudfrontDomainName,
|
|
117
|
+
evaluateTargetHealth: true,
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
allowOverwrite: true,
|
|
121
|
+
}, { parent: domainName });
|
|
122
|
+
new BasePathMapping('root', {
|
|
123
|
+
restApi: this.id,
|
|
124
|
+
stageName: stage.stageName,
|
|
125
|
+
domainName: domainName.domainName,
|
|
126
|
+
}, { parent: stage });
|
|
127
|
+
this.url = `https://${domain.fullName}/`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Bucket, type BucketArgs } from '@pulumi/aws/s3';
|
|
2
|
+
import type { CustomResourceOptions } from '@pulumi/pulumi';
|
|
3
|
+
type PublicS3BucketArgs = {
|
|
4
|
+
name: string;
|
|
5
|
+
allowPresignedPost?: boolean;
|
|
6
|
+
tags?: BucketArgs['tags'];
|
|
7
|
+
};
|
|
8
|
+
export declare class PublicS3Bucket extends Bucket {
|
|
9
|
+
constructor(id: string, args: PublicS3BucketArgs, opts?: CustomResourceOptions);
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Bucket, BucketAclV2, BucketCorsConfigurationV2, BucketOwnershipControls, BucketPolicy, BucketPublicAccessBlock, } from '@pulumi/aws/s3';
|
|
2
|
+
export class PublicS3Bucket extends Bucket {
|
|
3
|
+
constructor(id, args, opts) {
|
|
4
|
+
const { name, allowPresignedPost = false, tags } = args;
|
|
5
|
+
super(id, { bucket: name, tags }, opts);
|
|
6
|
+
const accessBlock = new BucketPublicAccessBlock('public-access', {
|
|
7
|
+
bucket: this.id,
|
|
8
|
+
blockPublicAcls: false,
|
|
9
|
+
blockPublicPolicy: false,
|
|
10
|
+
ignorePublicAcls: false,
|
|
11
|
+
restrictPublicBuckets: false,
|
|
12
|
+
}, { parent: this });
|
|
13
|
+
const ownershipControls = new BucketOwnershipControls('ownership', {
|
|
14
|
+
bucket: this.id,
|
|
15
|
+
rule: { objectOwnership: 'BucketOwnerPreferred' },
|
|
16
|
+
}, { parent: this, dependsOn: [accessBlock] });
|
|
17
|
+
new BucketAclV2('acl', {
|
|
18
|
+
bucket: this.id,
|
|
19
|
+
acl: 'public-read',
|
|
20
|
+
}, { parent: this, dependsOn: [ownershipControls] });
|
|
21
|
+
new BucketPolicy('policy', {
|
|
22
|
+
bucket: this.id,
|
|
23
|
+
policy: this.arn.apply((arn) => JSON.stringify({
|
|
24
|
+
Version: '2012-10-17',
|
|
25
|
+
Statement: [
|
|
26
|
+
{
|
|
27
|
+
Sid: 'Allow Public Access',
|
|
28
|
+
Effect: 'Allow',
|
|
29
|
+
Principal: '*',
|
|
30
|
+
Action: 's3:GetObject',
|
|
31
|
+
Resource: `${arn}/*`,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
})),
|
|
35
|
+
}, { parent: this, dependsOn: [accessBlock] });
|
|
36
|
+
new BucketCorsConfigurationV2('allowAll', {
|
|
37
|
+
bucket: this.bucket,
|
|
38
|
+
corsRules: [
|
|
39
|
+
{
|
|
40
|
+
maxAgeSeconds: 3000,
|
|
41
|
+
allowedMethods: allowPresignedPost ? ['GET', 'POST'] : ['GET'],
|
|
42
|
+
allowedHeaders: ['*'],
|
|
43
|
+
allowedOrigins: ['*'],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
}, { parent: this });
|
|
47
|
+
}
|
|
48
|
+
}
|
package/dist/s3/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CustomResourceOptions, type Input, Resource } from '@pulumi/pulumi';
|
|
2
|
+
import { type PublicS3Bucket } from '../s3';
|
|
3
|
+
export interface StaticWebsiteArgs {
|
|
4
|
+
projectId: string;
|
|
5
|
+
environmentName: string;
|
|
6
|
+
filesPath: string;
|
|
7
|
+
customDomain?: {
|
|
8
|
+
fullName: Input<string>;
|
|
9
|
+
zoneId: Input<string>;
|
|
10
|
+
usEast1CertificateArn: Input<string>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare class StaticWebsite extends Resource {
|
|
14
|
+
url: string;
|
|
15
|
+
bucket: PublicS3Bucket;
|
|
16
|
+
constructor(id: string, args: StaticWebsiteArgs, opts?: CustomResourceOptions);
|
|
17
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Resource } from '@pulumi/pulumi';
|
|
2
|
+
import { s3 } from '../s3';
|
|
3
|
+
import { BucketObject } from '@pulumi/aws/s3';
|
|
4
|
+
import { Distribution } from '@pulumi/aws/cloudfront';
|
|
5
|
+
import { Record } from '@pulumi/aws/route53';
|
|
6
|
+
import { readFilesRecursive } from './readFilesRecursive.js';
|
|
7
|
+
export class StaticWebsite extends Resource {
|
|
8
|
+
url;
|
|
9
|
+
bucket;
|
|
10
|
+
constructor(id, args, opts) {
|
|
11
|
+
super('mstuercke:website:StaticWebsite', id, false, undefined, opts);
|
|
12
|
+
const { projectId, environmentName, filesPath, customDomain } = args;
|
|
13
|
+
const bucket = new s3.PublicS3Bucket('bucket', {
|
|
14
|
+
name: `${projectId}-web-${environmentName}`,
|
|
15
|
+
allowPresignedPost: false,
|
|
16
|
+
tags: {
|
|
17
|
+
project: projectId,
|
|
18
|
+
},
|
|
19
|
+
}, { parent: this });
|
|
20
|
+
for (const file of readFilesRecursive(filesPath)) {
|
|
21
|
+
new BucketObject(file.relativePath, {
|
|
22
|
+
key: file.relativePath,
|
|
23
|
+
bucket: bucket.id,
|
|
24
|
+
source: file.absolutePath,
|
|
25
|
+
contentType: file.mimeType,
|
|
26
|
+
etag: file.md5,
|
|
27
|
+
tags: {
|
|
28
|
+
project: projectId,
|
|
29
|
+
},
|
|
30
|
+
}, { parent: bucket });
|
|
31
|
+
}
|
|
32
|
+
const cloudfront = new Distribution(`website`, {
|
|
33
|
+
enabled: true,
|
|
34
|
+
comment: `${projectId} (${environmentName})`,
|
|
35
|
+
defaultRootObject: 'index.html',
|
|
36
|
+
origins: [
|
|
37
|
+
{
|
|
38
|
+
domainName: bucket.bucketRegionalDomainName,
|
|
39
|
+
originId: bucket.id,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
defaultCacheBehavior: {
|
|
43
|
+
allowedMethods: ['GET', 'HEAD', 'OPTIONS'],
|
|
44
|
+
cachedMethods: ['GET', 'HEAD'],
|
|
45
|
+
targetOriginId: bucket.id,
|
|
46
|
+
viewerProtocolPolicy: 'redirect-to-https',
|
|
47
|
+
forwardedValues: {
|
|
48
|
+
queryString: false,
|
|
49
|
+
cookies: {
|
|
50
|
+
forward: 'none',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
orderedCacheBehaviors: [
|
|
55
|
+
{
|
|
56
|
+
pathPattern: 'index.html',
|
|
57
|
+
allowedMethods: ['GET', 'HEAD', 'OPTIONS'],
|
|
58
|
+
cachedMethods: ['GET', 'HEAD'],
|
|
59
|
+
targetOriginId: bucket.id,
|
|
60
|
+
viewerProtocolPolicy: 'redirect-to-https',
|
|
61
|
+
defaultTtl: 0,
|
|
62
|
+
maxTtl: 0,
|
|
63
|
+
forwardedValues: {
|
|
64
|
+
queryString: false,
|
|
65
|
+
cookies: {
|
|
66
|
+
forward: 'none',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
pathPattern: 'config.json',
|
|
72
|
+
allowedMethods: ['GET', 'HEAD', 'OPTIONS'],
|
|
73
|
+
cachedMethods: ['GET', 'HEAD'],
|
|
74
|
+
targetOriginId: bucket.id,
|
|
75
|
+
viewerProtocolPolicy: 'redirect-to-https',
|
|
76
|
+
defaultTtl: 0,
|
|
77
|
+
maxTtl: 0,
|
|
78
|
+
forwardedValues: {
|
|
79
|
+
queryString: false,
|
|
80
|
+
cookies: {
|
|
81
|
+
forward: 'none',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
customErrorResponses: [
|
|
87
|
+
{
|
|
88
|
+
errorCode: 404,
|
|
89
|
+
responsePagePath: '/index.html',
|
|
90
|
+
responseCode: 200,
|
|
91
|
+
errorCachingMinTtl: 0,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
restrictions: {
|
|
95
|
+
geoRestriction: {
|
|
96
|
+
restrictionType: 'none',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
viewerCertificate: customDomain
|
|
100
|
+
? {
|
|
101
|
+
acmCertificateArn: customDomain?.usEast1CertificateArn,
|
|
102
|
+
sslSupportMethod: 'sni-only',
|
|
103
|
+
minimumProtocolVersion: 'TLSv1.2_2019',
|
|
104
|
+
}
|
|
105
|
+
: { cloudfrontDefaultCertificate: true },
|
|
106
|
+
aliases: customDomain ? [customDomain?.fullName] : undefined,
|
|
107
|
+
tags: {
|
|
108
|
+
project: projectId,
|
|
109
|
+
},
|
|
110
|
+
}, { parent: this });
|
|
111
|
+
if (customDomain) {
|
|
112
|
+
new Record('redirect', {
|
|
113
|
+
zoneId: customDomain?.zoneId,
|
|
114
|
+
name: customDomain?.fullName,
|
|
115
|
+
type: 'A',
|
|
116
|
+
allowOverwrite: true,
|
|
117
|
+
aliases: [
|
|
118
|
+
{
|
|
119
|
+
zoneId: cloudfront.hostedZoneId,
|
|
120
|
+
name: cloudfront.domainName,
|
|
121
|
+
evaluateTargetHealth: false,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
}, { parent: this });
|
|
125
|
+
}
|
|
126
|
+
this.url = `https://${customDomain?.fullName || cloudfront.domainName}`;
|
|
127
|
+
this.bucket = bucket;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import mime from 'mime';
|
|
4
|
+
import { globSync } from 'glob';
|
|
5
|
+
export function readFilesRecursive(dir) {
|
|
6
|
+
const files = globSync(`${dir}/**/*`, { nodir: true });
|
|
7
|
+
return files.reduce((previousValue, fullPath) => {
|
|
8
|
+
const content = fs.readFileSync(fullPath, 'base64');
|
|
9
|
+
const md5 = createHash('md5').update(content, 'base64').digest('hex');
|
|
10
|
+
const mimeType = mime.getType(fullPath);
|
|
11
|
+
if (!mimeType)
|
|
12
|
+
throw `Cannot determine mimeType for ${fullPath}`;
|
|
13
|
+
return [
|
|
14
|
+
...previousValue,
|
|
15
|
+
{
|
|
16
|
+
absolutePath: fullPath,
|
|
17
|
+
relativePath: fullPath.replace(`${dir}/`, '').replace(dir, ''),
|
|
18
|
+
md5,
|
|
19
|
+
mimeType,
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
}, []);
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type CustomResourceOptions, type Input, type Output, Resource } from '@pulumi/pulumi';
|
|
2
|
+
import type { NodeLambdaFunction } from '../lambda';
|
|
3
|
+
export interface WebsocketApiArgs {
|
|
4
|
+
name: string;
|
|
5
|
+
lambdaFunction: NodeLambdaFunction;
|
|
6
|
+
routeThrottling?: {
|
|
7
|
+
rateLimit?: number;
|
|
8
|
+
burstLimit?: number;
|
|
9
|
+
};
|
|
10
|
+
stageName?: string;
|
|
11
|
+
domain: {
|
|
12
|
+
zoneId: Input<string>;
|
|
13
|
+
fullName: Input<string>;
|
|
14
|
+
euCentral1CertificateArn: Input<string>;
|
|
15
|
+
};
|
|
16
|
+
projectId: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class WebsocketApi extends Resource {
|
|
19
|
+
id: Output<string>;
|
|
20
|
+
url: string;
|
|
21
|
+
constructor(id: string, args: WebsocketApiArgs, opts?: CustomResourceOptions);
|
|
22
|
+
}
|