@mstuercke/pulumi-modules 0.0.5 → 0.0.6

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.
Files changed (52) hide show
  1. package/dist/auth0/Auth0.d.ts +29 -0
  2. package/dist/auth0/index.d.ts +5 -0
  3. package/dist/domain/getDomain.d.ts +13 -0
  4. package/dist/domain/index.d.ts +4 -0
  5. package/dist/iam/SimpleIamRolePolicy.d.ts +6 -0
  6. package/dist/iam/SimpleIamRolePolicyConfig.d.ts +57 -0
  7. package/dist/iam/index.d.ts +6 -0
  8. package/dist/index.d.ts +40 -0
  9. package/dist/lambda/NodeLambdaFunction.d.ts +20 -0
  10. package/dist/lambda/WithInputs.d.ts +4 -0
  11. package/dist/lambda/index.d.ts +5 -0
  12. package/dist/mongodb/MongoDB.d.ts +13 -0
  13. package/dist/mongodb/MongoDBCustomInstance.d.ts +12 -0
  14. package/dist/mongodb/MongoDBDefaultInstance.d.ts +12 -0
  15. package/dist/mongodb/MongoDBUser.d.ts +12 -0
  16. package/dist/mongodb/index.d.ts +11 -0
  17. package/dist/rest/RestApi.d.ts +19 -0
  18. package/dist/rest/index.d.ts +5 -0
  19. package/dist/s3/PublicS3Bucket.d.ts +11 -0
  20. package/dist/s3/index.d.ts +5 -0
  21. package/dist/website/StaticWebsite.d.ts +17 -0
  22. package/dist/website/index.d.ts +5 -0
  23. package/dist/website/readFilesRecursive.d.ts +8 -0
  24. package/dist/websocket/WebsocketApi.d.ts +22 -0
  25. package/dist/websocket/index.d.ts +5 -0
  26. package/package.json +4 -4
  27. package/src/auth0/Auth0.ts +0 -162
  28. package/src/auth0/index.ts +0 -7
  29. package/src/domain/getDomain.ts +0 -32
  30. package/src/domain/index.ts +0 -7
  31. package/src/iam/SimpleIamRolePolicy.ts +0 -164
  32. package/src/iam/SimpleIamRolePolicyConfig.ts +0 -75
  33. package/src/iam/index.ts +0 -8
  34. package/src/index.ts +0 -31
  35. package/src/lambda/NodeLambdaFunction.ts +0 -119
  36. package/src/lambda/WithInputs.ts +0 -5
  37. package/src/lambda/index.ts +0 -7
  38. package/src/mongodb/MongoDB.ts +0 -86
  39. package/src/mongodb/MongoDBCustomInstance.ts +0 -56
  40. package/src/mongodb/MongoDBDefaultInstance.ts +0 -34
  41. package/src/mongodb/MongoDBUser.ts +0 -48
  42. package/src/mongodb/index.ts +0 -13
  43. package/src/rest/RestApi.ts +0 -227
  44. package/src/rest/index.ts +0 -7
  45. package/src/s3/PublicS3Bucket.ts +0 -92
  46. package/src/s3/index.ts +0 -7
  47. package/src/website/StaticWebsite.ts +0 -175
  48. package/src/website/index.ts +0 -7
  49. package/src/website/readFilesRecursive.ts +0 -33
  50. package/src/websocket/WebsocketApi.ts +0 -219
  51. package/src/websocket/index.ts +0 -7
  52. package/tsconfig.json +0 -6
@@ -1,227 +0,0 @@
1
- import * as aws from '@pulumi/aws'
2
- import {apigateway, lambda} from '@pulumi/aws'
3
- import type {CustomResourceOptions, Input} from '@pulumi/pulumi'
4
- import {Record} from '@pulumi/aws/route53'
5
- import {BasePathMapping, DomainName} from '@pulumi/aws/apigateway'
6
- import type {NodeLambdaFunction} from '../lambda/index.ts'
7
-
8
- export interface RestApiArgs {
9
- name: string
10
- projectId: string
11
- lambdaFunction: NodeLambdaFunction
12
- timeoutSeconds?: number
13
- stageName?: string
14
- domain: {
15
- zoneId: Input<string>
16
- fullName: Input<string>
17
- usEast1CertificateArn: Input<string>
18
- }
19
- }
20
-
21
- export class RestApi extends aws.apigateway.RestApi {
22
- readonly url: string
23
-
24
- constructor(id: string, args: RestApiArgs, opts?: CustomResourceOptions) {
25
- const {name, projectId, stageName = 'v1', domain} = args
26
- super(
27
- id,
28
- {
29
- name,
30
- tags: {
31
- project: projectId,
32
- },
33
- },
34
- opts,
35
- )
36
-
37
- const {lambdaFunction, timeoutSeconds = 29} = args
38
-
39
- const proxyResource = new apigateway.Resource(
40
- `proxy`,
41
- {
42
- restApi: this.id,
43
- parentId: this.rootResourceId,
44
- pathPart: '{proxy+}',
45
- },
46
- {parent: this},
47
- )
48
-
49
- const proxyMethod = new apigateway.Method(
50
- `proxy`,
51
- {
52
- restApi: this.id,
53
- resourceId: proxyResource.id,
54
- httpMethod: 'ANY',
55
- authorization: 'NONE',
56
- },
57
- {parent: proxyResource},
58
- )
59
-
60
- const lambdaIntegration = new apigateway.Integration(
61
- `proxy`,
62
- {
63
- restApi: this.id,
64
- resourceId: proxyResource.id,
65
- httpMethod: proxyMethod.httpMethod,
66
- integrationHttpMethod: 'POST',
67
- type: 'AWS_PROXY',
68
- uri: lambdaFunction.invokeArn,
69
- timeoutMilliseconds: timeoutSeconds * 1000,
70
- },
71
- {parent: proxyMethod},
72
- )
73
-
74
- const proxyOptionsMethod = new apigateway.Method(
75
- `options`,
76
- {
77
- restApi: this.id,
78
- resourceId: proxyResource.id,
79
- httpMethod: 'OPTIONS',
80
- authorization: 'NONE',
81
- },
82
- {parent: proxyResource},
83
- )
84
-
85
- const lambdaIntegrationOptions = new apigateway.Integration(
86
- `options`,
87
- {
88
- restApi: this.id,
89
- resourceId: proxyResource.id,
90
- httpMethod: proxyOptionsMethod.httpMethod,
91
- integrationHttpMethod: 'POST',
92
- type: 'AWS_PROXY',
93
- uri: lambdaFunction.invokeArn,
94
- timeoutMilliseconds: timeoutSeconds * 1000,
95
- },
96
- {parent: proxyOptionsMethod},
97
- )
98
-
99
- const proxyRootMethod = new apigateway.Method(
100
- `proxy-root`,
101
- {
102
- restApi: this.id,
103
- resourceId: this.rootResourceId,
104
- httpMethod: 'ANY',
105
- authorization: 'NONE',
106
- },
107
- {parent: this},
108
- )
109
-
110
- const lambdaRootIntegration = new apigateway.Integration(
111
- `proxy-root`,
112
- {
113
- restApi: this.id,
114
- resourceId: proxyRootMethod.resourceId,
115
- httpMethod: proxyRootMethod.httpMethod,
116
- integrationHttpMethod: 'POST',
117
- type: 'AWS_PROXY',
118
- uri: lambdaFunction.invokeArn,
119
- timeoutMilliseconds: timeoutSeconds * 1000,
120
- },
121
- {parent: proxyRootMethod},
122
- )
123
-
124
- const proxyRootOptionsMethod = new apigateway.Method(
125
- `proxy-root-options`,
126
- {
127
- restApi: this.id,
128
- resourceId: this.rootResourceId,
129
- httpMethod: 'OPTIONS',
130
- authorization: 'NONE',
131
- },
132
- {parent: this},
133
- )
134
-
135
- const lambdaRootIntegrationOptions = new apigateway.Integration(
136
- `proxy-root-options`,
137
- {
138
- restApi: this.id,
139
- resourceId: proxyRootOptionsMethod.resourceId,
140
- httpMethod: proxyRootOptionsMethod.httpMethod,
141
- integrationHttpMethod: 'POST',
142
- type: 'AWS_PROXY',
143
- uri: lambdaFunction.invokeArn,
144
- timeoutMilliseconds: timeoutSeconds * 1000,
145
- },
146
- {parent: proxyRootOptionsMethod},
147
- )
148
-
149
- new lambda.Permission(
150
- `rest-api`,
151
- {
152
- statementId: 'AllowRestApiInvoke',
153
- action: 'lambda:InvokeFunction',
154
- function: lambdaFunction.name,
155
- principal: 'apigateway.amazonaws.com',
156
- sourceArn: this.executionArn.apply((executionArn) => `${executionArn}/*`),
157
- },
158
- {parent: lambdaFunction},
159
- )
160
-
161
- const deployment = new apigateway.Deployment(
162
- stageName,
163
- {restApi: this.id},
164
- {
165
- dependsOn: [
166
- proxyMethod,
167
- lambdaIntegration,
168
- lambdaIntegrationOptions,
169
- proxyRootMethod,
170
- lambdaRootIntegration,
171
- lambdaRootIntegrationOptions,
172
- ],
173
- parent: this,
174
- },
175
- )
176
-
177
- const stage = new apigateway.Stage(
178
- stageName,
179
- {
180
- restApi: this.id,
181
- stageName: stageName,
182
- deployment: deployment.id,
183
- tags: {project: projectId},
184
- },
185
- {parent: deployment},
186
- )
187
-
188
- const domainName = new DomainName(
189
- 'domain',
190
- {
191
- domainName: domain.fullName,
192
- certificateArn: domain.usEast1CertificateArn,
193
- },
194
- {parent: this},
195
- )
196
-
197
- new Record(
198
- 'redirect',
199
- {
200
- zoneId: domain.zoneId,
201
- name: domain.fullName,
202
- type: 'A',
203
- aliases: [
204
- {
205
- zoneId: domainName.cloudfrontZoneId,
206
- name: domainName.cloudfrontDomainName,
207
- evaluateTargetHealth: true,
208
- },
209
- ],
210
- allowOverwrite: true,
211
- },
212
- {parent: domainName},
213
- )
214
-
215
- new BasePathMapping(
216
- 'root',
217
- {
218
- restApi: this.id,
219
- stageName: stage.stageName,
220
- domainName: domainName.domainName,
221
- },
222
- {parent: stage},
223
- )
224
-
225
- this.url = `https://${domain.fullName}/`
226
- }
227
- }
package/src/rest/index.ts DELETED
@@ -1,7 +0,0 @@
1
- import {RestApi} from './RestApi.ts'
2
-
3
- export * from './RestApi.ts'
4
-
5
- export const rest = {
6
- RestApi,
7
- }
@@ -1,92 +0,0 @@
1
- import {
2
- Bucket,
3
- BucketAclV2,
4
- type BucketArgs,
5
- BucketCorsConfigurationV2,
6
- BucketOwnershipControls,
7
- BucketPolicy,
8
- BucketPublicAccessBlock,
9
- } from '@pulumi/aws/s3'
10
- import type {CustomResourceOptions} from '@pulumi/pulumi'
11
-
12
- type PublicS3BucketArgs = {
13
- name: string
14
- allowPresignedPost?: boolean
15
- tags?: BucketArgs['tags']
16
- }
17
-
18
- export class PublicS3Bucket extends Bucket {
19
- constructor(id: string, args: PublicS3BucketArgs, opts?: CustomResourceOptions) {
20
- const {name, allowPresignedPost = false, tags} = args
21
-
22
- super(id, {bucket: name, tags}, opts)
23
-
24
- const accessBlock = new BucketPublicAccessBlock(
25
- 'public-access',
26
- {
27
- bucket: this.id,
28
- blockPublicAcls: false,
29
- blockPublicPolicy: false,
30
- ignorePublicAcls: false,
31
- restrictPublicBuckets: false,
32
- },
33
- {parent: this},
34
- )
35
-
36
- const ownershipControls = new BucketOwnershipControls(
37
- 'ownership',
38
- {
39
- bucket: this.id,
40
- rule: {objectOwnership: 'BucketOwnerPreferred'},
41
- },
42
- {parent: this, dependsOn: [accessBlock]},
43
- )
44
-
45
- new BucketAclV2(
46
- 'acl',
47
- {
48
- bucket: this.id,
49
- acl: 'public-read',
50
- },
51
- {parent: this, dependsOn: [ownershipControls]},
52
- )
53
-
54
- new BucketPolicy(
55
- 'policy',
56
- {
57
- bucket: this.id,
58
- policy: this.arn.apply((arn) =>
59
- JSON.stringify({
60
- Version: '2012-10-17',
61
- Statement: [
62
- {
63
- Sid: 'Allow Public Access',
64
- Effect: 'Allow',
65
- Principal: '*',
66
- Action: 's3:GetObject',
67
- Resource: `${arn}/*`,
68
- },
69
- ],
70
- }),
71
- ),
72
- },
73
- {parent: this, dependsOn: [accessBlock]},
74
- )
75
-
76
- new BucketCorsConfigurationV2(
77
- 'allowAll',
78
- {
79
- bucket: this.bucket,
80
- corsRules: [
81
- {
82
- maxAgeSeconds: 3000,
83
- allowedMethods: allowPresignedPost ? ['GET', 'POST'] : ['GET'],
84
- allowedHeaders: ['*'],
85
- allowedOrigins: ['*'],
86
- },
87
- ],
88
- },
89
- {parent: this},
90
- )
91
- }
92
- }
package/src/s3/index.ts DELETED
@@ -1,7 +0,0 @@
1
- import {PublicS3Bucket} from './PublicS3Bucket.ts'
2
-
3
- export * from './PublicS3Bucket.ts'
4
-
5
- export const s3 = {
6
- PublicS3Bucket,
7
- }
@@ -1,175 +0,0 @@
1
- import {type CustomResourceOptions, type Input, Resource} from '@pulumi/pulumi'
2
- import {type PublicS3Bucket, s3} from '../s3/index.ts'
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
-
8
- export interface StaticWebsiteArgs {
9
- projectId: string
10
- environmentName: string
11
- filesPath: string
12
- customDomain?: {
13
- fullName: Input<string>
14
- zoneId: Input<string>
15
- usEast1CertificateArn: Input<string>
16
- }
17
- }
18
-
19
- export class StaticWebsite extends Resource {
20
- public url: string
21
- public bucket: PublicS3Bucket
22
-
23
- constructor(id: string, args: StaticWebsiteArgs, opts?: CustomResourceOptions) {
24
- super('mstuercke:website:StaticWebsite', id, false, undefined, opts)
25
-
26
- const {projectId, environmentName, filesPath, customDomain} = args
27
-
28
- const bucket = new s3.PublicS3Bucket(
29
- 'bucket',
30
- {
31
- name: `${projectId}-web-${environmentName}`,
32
- allowPresignedPost: false,
33
- tags: {
34
- project: projectId,
35
- },
36
- },
37
- {parent: this},
38
- )
39
-
40
- for (const file of readFilesRecursive(filesPath)) {
41
- new BucketObject(
42
- file.relativePath,
43
- {
44
- key: file.relativePath,
45
- bucket: bucket.id,
46
- source: file.absolutePath,
47
- contentType: file.mimeType,
48
- etag: file.md5,
49
- tags: {
50
- project: projectId,
51
- },
52
- },
53
- {parent: bucket},
54
- )
55
- }
56
-
57
- const cloudfront = new Distribution(
58
- `website`,
59
- {
60
- enabled: true,
61
- comment: `${projectId} (${environmentName})`,
62
- defaultRootObject: 'index.html',
63
-
64
- origins: [
65
- {
66
- domainName: bucket.bucketRegionalDomainName,
67
- originId: bucket.id,
68
- },
69
- ],
70
-
71
- defaultCacheBehavior: {
72
- allowedMethods: ['GET', 'HEAD', 'OPTIONS'],
73
- cachedMethods: ['GET', 'HEAD'],
74
- targetOriginId: bucket.id,
75
- viewerProtocolPolicy: 'redirect-to-https',
76
-
77
- forwardedValues: {
78
- queryString: false,
79
- cookies: {
80
- forward: 'none',
81
- },
82
- },
83
- },
84
-
85
- orderedCacheBehaviors: [
86
- {
87
- pathPattern: 'index.html',
88
- allowedMethods: ['GET', 'HEAD', 'OPTIONS'],
89
- cachedMethods: ['GET', 'HEAD'],
90
- targetOriginId: bucket.id,
91
- viewerProtocolPolicy: 'redirect-to-https',
92
- defaultTtl: 0,
93
- maxTtl: 0,
94
-
95
- forwardedValues: {
96
- queryString: false,
97
- cookies: {
98
- forward: 'none',
99
- },
100
- },
101
- },
102
- {
103
- pathPattern: 'config.json',
104
- allowedMethods: ['GET', 'HEAD', 'OPTIONS'],
105
- cachedMethods: ['GET', 'HEAD'],
106
- targetOriginId: bucket.id,
107
- viewerProtocolPolicy: 'redirect-to-https',
108
- defaultTtl: 0,
109
- maxTtl: 0,
110
-
111
- forwardedValues: {
112
- queryString: false,
113
- cookies: {
114
- forward: 'none',
115
- },
116
- },
117
- },
118
- ],
119
-
120
- customErrorResponses: [
121
- {
122
- errorCode: 404,
123
- responsePagePath: '/index.html',
124
- responseCode: 200,
125
- errorCachingMinTtl: 0,
126
- },
127
- ],
128
-
129
- restrictions: {
130
- geoRestriction: {
131
- restrictionType: 'none',
132
- },
133
- },
134
-
135
- viewerCertificate: customDomain
136
- ? {
137
- acmCertificateArn: customDomain?.usEast1CertificateArn,
138
- sslSupportMethod: 'sni-only',
139
- minimumProtocolVersion: 'TLSv1.2_2019',
140
- }
141
- : {cloudfrontDefaultCertificate: true},
142
-
143
- aliases: customDomain ? [customDomain?.fullName] : undefined,
144
-
145
- tags: {
146
- project: projectId,
147
- },
148
- },
149
- {parent: this},
150
- )
151
-
152
- if (customDomain) {
153
- new Record(
154
- 'redirect',
155
- {
156
- zoneId: customDomain?.zoneId,
157
- name: customDomain?.fullName,
158
- type: 'A',
159
- allowOverwrite: true,
160
- aliases: [
161
- {
162
- zoneId: cloudfront.hostedZoneId,
163
- name: cloudfront.domainName,
164
- evaluateTargetHealth: false,
165
- },
166
- ],
167
- },
168
- {parent: this},
169
- )
170
- }
171
-
172
- this.url = `https://${customDomain?.fullName || cloudfront.domainName}`
173
- this.bucket = bucket
174
- }
175
- }
@@ -1,7 +0,0 @@
1
- import {StaticWebsite} from './StaticWebsite.ts'
2
-
3
- export * from './StaticWebsite.ts'
4
-
5
- export const website = {
6
- StaticWebsite,
7
- }
@@ -1,33 +0,0 @@
1
- import {createHash} from 'crypto'
2
- import fs from 'fs'
3
- import mime from 'mime'
4
- import {globSync} from 'glob'
5
-
6
- interface File {
7
- absolutePath: string
8
- relativePath: string
9
- md5: string
10
- mimeType: string
11
- }
12
-
13
- export function readFilesRecursive(dir: string): File[] {
14
- const files = globSync(`${dir}/**/*`, {nodir: true})
15
-
16
- return files.reduce((previousValue, fullPath) => {
17
- const content = fs.readFileSync(fullPath, 'base64')
18
- const md5 = createHash('md5').update(content, 'base64').digest('hex')
19
-
20
- const mimeType = mime.getType(fullPath)
21
- if (!mimeType) throw `Cannot determine mimeType for ${fullPath}`
22
-
23
- return [
24
- ...previousValue,
25
- {
26
- absolutePath: fullPath,
27
- relativePath: fullPath.replace(`${dir}/`, '').replace(dir, ''),
28
- md5,
29
- mimeType,
30
- },
31
- ]
32
- }, [] as File[])
33
- }