@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,164 +0,0 @@
1
- import {iam} from '@pulumi/aws'
2
- import type {SimpleIamRolePolicyConfig} from './SimpleIamRolePolicyConfig.js'
3
- import {type CustomResourceOptions, type Input, output} from '@pulumi/pulumi'
4
- import type {PolicyStatement, RolePolicyArgs} from '@pulumi/aws/iam'
5
-
6
- export class SimpleIamRolePolicy extends iam.RolePolicy {
7
- constructor(iamRoleId: string, config: SimpleIamRolePolicyConfig, opts?: CustomResourceOptions) {
8
- switch (config.type) {
9
- case 'custom':
10
- super(config.name, mapIamRolePolicyConfig(iamRoleId, config.name, config.statements), opts)
11
- break
12
-
13
- case 'dynamodb':
14
- if (config.level !== 'full-access') throw mapError(config)
15
- super(
16
- config.name,
17
- mapIamRolePolicyConfig(iamRoleId, config.name, [
18
- {
19
- Action: ['dynamodb:*'],
20
- Effect: 'Allow',
21
- Resource: output(config.tableArn).apply((tableArn) => [`${tableArn}`, `${tableArn}/*`]),
22
- },
23
- ]),
24
- opts,
25
- )
26
- break
27
-
28
- case 'timestream':
29
- if (config.level !== 'full-access') throw mapError(config)
30
-
31
- super(
32
- config.name,
33
- mapIamRolePolicyConfig(iamRoleId, config.name, [
34
- {
35
- Action: ['timestream:*'],
36
- Effect: 'Allow',
37
- Resource: [config.dbArn, config.tableArn],
38
- },
39
- {
40
- Action: ['timestream:DescribeEndpoints'],
41
- Effect: 'Allow',
42
- Resource: ['*'],
43
- },
44
- ]),
45
- opts,
46
- )
47
- break
48
-
49
- case 's3':
50
- if (config.level !== 'full-access') throw mapError(config)
51
-
52
- super(
53
- config.name,
54
- mapIamRolePolicyConfig(iamRoleId, config.name, [
55
- {
56
- Action: ['s3:*'],
57
- Effect: 'Allow',
58
- Resource: output(config.bucketArn).apply((bucketArn) => [`${bucketArn}`, `${bucketArn}/*`]),
59
- },
60
- ]),
61
- opts,
62
- )
63
- break
64
-
65
- case 'cognito':
66
- if (config.level !== 'full-access') throw mapError(config)
67
-
68
- super(
69
- config.name,
70
- mapIamRolePolicyConfig(iamRoleId, config.name, [
71
- {
72
- Action: ['cognito-idp:*'],
73
- Effect: 'Allow',
74
- Resource: [config.userPoolArn],
75
- },
76
- ]),
77
- opts,
78
- )
79
- break
80
-
81
- case 'websocket':
82
- if (config.level !== 'full-access') throw mapError(config)
83
-
84
- super(
85
- config.name,
86
- mapIamRolePolicyConfig(iamRoleId, config.name, [
87
- {
88
- Effect: 'Allow',
89
- Action: 'execute-api:*',
90
- Resource: config.apiArn,
91
- },
92
- ]),
93
- opts,
94
- )
95
- break
96
-
97
- case 'sns':
98
- if (config.level !== 'publish-message') throw mapError(config)
99
-
100
- super(
101
- config.name,
102
- mapIamRolePolicyConfig(iamRoleId, config.name, [
103
- {
104
- Effect: 'Allow',
105
- Action: 'sns:Publish',
106
- Resource: config.snsTopicArn,
107
- },
108
- ]),
109
- opts,
110
- )
111
- break
112
-
113
- case 'execute-lambda':
114
- super(
115
- config.name,
116
- mapIamRolePolicyConfig(iamRoleId, config.name, [
117
- {
118
- Effect: 'Allow',
119
- Action: 'lambda:InvokeFunction',
120
- Resource: config.lambdaArn,
121
- },
122
- ]),
123
- opts,
124
- )
125
- break
126
-
127
- case 'event-bridge':
128
- super(
129
- config.name,
130
- mapIamRolePolicyConfig(iamRoleId, config.name, [
131
- {
132
- Effect: 'Allow',
133
- Action: ['events:DescribeRule', 'events:DisableRule', 'events:EnableRule'],
134
- Resource: config.ruleArn,
135
- },
136
- ]),
137
- opts,
138
- )
139
- break
140
-
141
- default:
142
- throw mapError(config)
143
- }
144
- }
145
- }
146
-
147
- function mapIamRolePolicyConfig(
148
- iamRoleId: Input<string>,
149
- name: string,
150
- statements: Input<Input<PolicyStatement>[]>,
151
- ): RolePolicyArgs {
152
- return {
153
- role: iamRoleId,
154
- name: name,
155
- policy: {
156
- Version: '2012-10-17',
157
- Statement: statements,
158
- },
159
- }
160
- }
161
-
162
- function mapError(config: SimpleIamRolePolicyConfig): Error {
163
- return new Error(`Unable to create policy with config: ${JSON.stringify(config)}`)
164
- }
@@ -1,75 +0,0 @@
1
- import type {Input} from '@pulumi/pulumi'
2
- import type {PolicyStatement} from '@pulumi/aws/iam'
3
-
4
- export type SimpleIamRolePolicyConfig =
5
- | CustomPolicyConfig
6
- | DynamoDbPolicyConfig
7
- | TimestreamPolicyConfig
8
- | S3PolicyConfig
9
- | CognitoPolicyConfig
10
- | WebsocketPolicyConfig
11
- | ExecuteLambdaConfig
12
- | SnsPolicyConfig
13
- | EventBridgeConfig
14
-
15
- interface CustomPolicyConfig {
16
- type: 'custom'
17
- name: string
18
- statements: PolicyStatement[]
19
- }
20
-
21
- interface DynamoDbPolicyConfig {
22
- type: 'dynamodb'
23
- level: 'full-access'
24
- name: string
25
- tableArn: Input<string>
26
- }
27
-
28
- interface TimestreamPolicyConfig {
29
- type: 'timestream'
30
- level: 'full-access'
31
- name: string
32
- dbArn: Input<string>
33
- tableArn: Input<string>
34
- }
35
-
36
- interface S3PolicyConfig {
37
- type: 's3'
38
- level: 'full-access'
39
- name: string
40
- bucketArn: Input<string>
41
- }
42
-
43
- interface CognitoPolicyConfig {
44
- type: 'cognito'
45
- level: 'full-access'
46
- name: string
47
- userPoolArn: Input<string>
48
- }
49
-
50
- interface WebsocketPolicyConfig {
51
- type: 'websocket'
52
- level: 'full-access'
53
- name: string
54
- apiArn: '*'
55
- }
56
-
57
- interface SnsPolicyConfig {
58
- type: 'sns'
59
- level: 'publish-message'
60
- name: string
61
- snsTopicArn: Input<string>
62
- }
63
-
64
- interface ExecuteLambdaConfig {
65
- type: 'execute-lambda'
66
- name: string
67
- lambdaArn: Input<string>
68
- }
69
-
70
- interface EventBridgeConfig {
71
- type: 'event-bridge'
72
- level: 'enable-disable-rule'
73
- name: string
74
- ruleArn: Input<string>
75
- }
package/src/iam/index.ts DELETED
@@ -1,8 +0,0 @@
1
- import {SimpleIamRolePolicy} from './SimpleIamRolePolicy.ts'
2
-
3
- export * from './SimpleIamRolePolicy.ts'
4
- export * from './SimpleIamRolePolicyConfig.ts'
5
-
6
- export const iam = {
7
- SimpleIamRolePolicy,
8
- }
package/src/index.ts DELETED
@@ -1,31 +0,0 @@
1
- import {auth0} from './auth0/index.ts'
2
- import {domain} from './domain/index.ts'
3
- import {iam} from './iam/index.ts'
4
- import {rest} from './rest/index.ts'
5
- import {lambda} from './lambda/index.ts'
6
- import {mongodb} from './mongodb/index.ts'
7
- import {s3} from './s3/index.ts'
8
- import {website} from './website/index.ts'
9
- import {websocket} from './websocket/index.ts'
10
-
11
- export * from './auth0/index.ts'
12
- export * from './domain/index.ts'
13
- export * from './iam/index.ts'
14
- export * from './lambda/index.ts'
15
- export * from './mongodb/index.ts'
16
- export * from './rest/index.ts'
17
- export * from './s3/index.ts'
18
- export * from './website/index.ts'
19
- export * from './websocket/index.ts'
20
-
21
- export const mstuercke = {
22
- auth0,
23
- domain,
24
- iam,
25
- lambda,
26
- mongodb,
27
- rest,
28
- s3,
29
- website,
30
- websocket: websocket,
31
- }
@@ -1,119 +0,0 @@
1
- import {iam, lambda} from '@pulumi/aws'
2
- import {getFile} from '@pulumi/archive'
3
- import {asset, type CustomResourceOptions, type Output, Resource} from '@pulumi/pulumi'
4
-
5
- import {SimpleIamRolePolicy, type SimpleIamRolePolicyConfig} from '../iam/index.ts'
6
- import type {WithInputs} from './WithInputs.js'
7
-
8
- export type NodeLambdaFunctionArgs<EnvironmentVariables> = {
9
- name: string
10
- runtime?: string
11
- functionHandler?: string
12
- memorySize?: number
13
- timeoutSeconds?: number
14
- lambdaPath: string
15
- additionalIamRolePolicies?: SimpleIamRolePolicyConfig[]
16
- environmentVariables?: WithInputs<EnvironmentVariables>
17
- projectId: string
18
- }
19
-
20
- export class NodeLambdaFunction<
21
- EnvironmentVariables extends Record<string, string> = Record<string, string>,
22
- > extends Resource {
23
- name: string
24
- arn: Output<string>
25
- invokeArn: Output<string>
26
-
27
- constructor(args: NodeLambdaFunctionArgs<EnvironmentVariables>, opts?: CustomResourceOptions) {
28
- super('mstuercke:lambda:NodeLambdaFunction', args.name, false, undefined, opts)
29
- const {
30
- name,
31
- additionalIamRolePolicies = [],
32
- environmentVariables = undefined,
33
- runtime = 'nodejs22.x',
34
- functionHandler = 'lambdaFunction.lambdaHandler',
35
- memorySize = 128,
36
- timeoutSeconds = 30,
37
- projectId,
38
- } = args
39
-
40
- const role = new iam.Role(
41
- name,
42
- {
43
- name: `${name}-lambda`,
44
- assumeRolePolicy: JSON.stringify({
45
- Version: '2012-10-17',
46
- Statement: [
47
- {
48
- Action: 'sts:AssumeRole',
49
- Principal: {Service: 'lambda.amazonaws.com'},
50
- Effect: 'Allow',
51
- },
52
- ],
53
- }),
54
- tags: {
55
- project: projectId,
56
- },
57
- },
58
- {parent: this},
59
- )
60
-
61
- role.id.apply((roleId) => {
62
- new SimpleIamRolePolicy(
63
- roleId,
64
- {
65
- type: 'custom',
66
- name: 'logging',
67
- statements: [
68
- {
69
- Effect: 'Allow',
70
- Action: ['logs:CreateLogGroup', 'logs:CreateLogStream', 'logs:PutLogEvents'],
71
- Resource: '*',
72
- },
73
- ],
74
- },
75
- {parent: this},
76
- )
77
-
78
- for (const config of additionalIamRolePolicies) {
79
- new SimpleIamRolePolicy(roleId, config, {parent: this})
80
- }
81
- })
82
-
83
- const lambdaZip = getFile({
84
- type: 'zip',
85
- sourceDir: args.lambdaPath,
86
- outputPath: `dist/lambda/${name}.zip`,
87
- })
88
-
89
- const lambdaFunction = new lambda.Function(
90
- name,
91
- {
92
- name: name,
93
- handler: functionHandler,
94
- runtime: runtime,
95
- memorySize: memorySize,
96
- timeout: timeoutSeconds,
97
-
98
- code: new asset.FileArchive(lambdaZip.then((lambdaZip) => lambdaZip.outputPath)),
99
- sourceCodeHash: lambdaZip.then((lambdaZip) => lambdaZip.outputBase64sha256),
100
-
101
- role: role.arn,
102
-
103
- environment: {
104
- variables: {
105
- ...environmentVariables,
106
- },
107
- },
108
- tags: {
109
- project: projectId,
110
- },
111
- },
112
- {parent: this},
113
- )
114
-
115
- this.name = name
116
- this.arn = lambdaFunction.arn
117
- this.invokeArn = lambdaFunction.invokeArn
118
- }
119
- }
@@ -1,5 +0,0 @@
1
- import type {Input} from '@pulumi/pulumi'
2
-
3
- export type WithInputs<T> = {
4
- [key in keyof T]: Input<T[key]>
5
- }
@@ -1,7 +0,0 @@
1
- import {NodeLambdaFunction} from './NodeLambdaFunction.ts'
2
-
3
- export * from './NodeLambdaFunction.ts'
4
-
5
- export const lambda = {
6
- NodeLambdaFunction,
7
- }
@@ -1,86 +0,0 @@
1
- import {type CustomResourceOptions, type Output, Resource} from '@pulumi/pulumi'
2
- import {RandomPassword} from '@pulumi/random'
3
- import {DatabaseUser, Project, ProjectIpAccessList, Provider, ServerlessInstance} from '@pulumi/mongodbatlas'
4
-
5
- export type MongoDBArgs = {
6
- organizationId: string
7
- projectId: string
8
- environmentName: string
9
- }
10
-
11
- export class MongoDB extends Resource {
12
- readonly connectionString: Output<string>
13
- readonly databaseName: string
14
- readonly username: string
15
- readonly password: Output<string>
16
-
17
- constructor(args: MongoDBArgs, opts?: CustomResourceOptions) {
18
- const {organizationId, projectId, environmentName} = args
19
- super('mstuercke:mongodb:MongoDB', organizationId, false, undefined, opts)
20
-
21
- new Provider('provider', {}, {parent: this})
22
-
23
- const mongoProject = new Project(
24
- 'project',
25
- {
26
- orgId: organizationId,
27
- name: `${projectId}-${environmentName}`,
28
- tags: {
29
- project: projectId,
30
- },
31
- },
32
- {parent: this},
33
- )
34
-
35
- new ProjectIpAccessList(
36
- 'network-access',
37
- {
38
- projectId: mongoProject.id,
39
- cidrBlock: '0.0.0.0/0',
40
- },
41
- {parent: mongoProject},
42
- )
43
-
44
- const mongoInstance = new ServerlessInstance(
45
- 'database',
46
- {
47
- projectId: mongoProject.id,
48
- name: `${projectId}-${environmentName}`,
49
- providerSettingsBackingProviderName: 'AWS',
50
- providerSettingsProviderName: 'SERVERLESS',
51
- providerSettingsRegionName: 'EU_WEST_1', // Ireland
52
- },
53
- {parent: mongoProject},
54
- )
55
-
56
- const username = `${projectId}-${environmentName}`
57
- const password = new RandomPassword(
58
- 'password',
59
- {
60
- length: 32,
61
- },
62
- {parent: mongoProject},
63
- )
64
-
65
- const databaseName = projectId
66
- new DatabaseUser(
67
- 'user',
68
- {
69
- projectId: mongoProject.id,
70
- username,
71
- password: password.result,
72
- authDatabaseName: 'admin',
73
- roles: [
74
- {roleName: 'dbAdmin', databaseName},
75
- {roleName: 'readWrite', databaseName},
76
- ],
77
- },
78
- {parent: mongoProject},
79
- )
80
-
81
- this.connectionString = mongoInstance.connectionStringsStandardSrv
82
- this.databaseName = databaseName
83
- this.username = username
84
- this.password = password.result
85
- }
86
- }
@@ -1,56 +0,0 @@
1
- import {type CustomResourceOptions, type Output, Resource} from '@pulumi/pulumi'
2
- import {Project, ProjectIpAccessList, ServerlessInstance} from '@pulumi/mongodbatlas'
3
-
4
- export type MongoDBCustomInstanceArgs = {
5
- organizationId: string
6
- projectId: string
7
- environmentName: string
8
- }
9
-
10
- export class MongoDBCustomInstance extends Resource {
11
- readonly mongoProjectId: Output<string>
12
- readonly connectionString: Output<string>
13
- readonly databaseName: string
14
-
15
- constructor(args: MongoDBCustomInstanceArgs, opts?: CustomResourceOptions) {
16
- const {organizationId, projectId, environmentName} = args
17
- super('mstuercke:mongodb:MongoDBCustomInstance', organizationId, false, undefined, opts)
18
-
19
- const mongoProject = new Project(
20
- 'project',
21
- {
22
- orgId: organizationId,
23
- name: `${projectId}-${environmentName}`,
24
- tags: {
25
- project: projectId,
26
- },
27
- },
28
- {parent: this},
29
- )
30
-
31
- new ProjectIpAccessList(
32
- 'network-access',
33
- {
34
- projectId: mongoProject.id,
35
- cidrBlock: '0.0.0.0/0',
36
- },
37
- {parent: this},
38
- )
39
-
40
- const mongoInstance = new ServerlessInstance(
41
- 'database',
42
- {
43
- projectId: mongoProject.id,
44
- name: `${projectId}-${environmentName}`,
45
- providerSettingsBackingProviderName: 'AWS',
46
- providerSettingsProviderName: 'SERVERLESS',
47
- providerSettingsRegionName: 'EU_WEST_1', // Ireland
48
- },
49
- {parent: this},
50
- )
51
-
52
- this.mongoProjectId = mongoProject.id
53
- this.connectionString = mongoInstance.connectionStringsStandardSrv
54
- this.databaseName = `${projectId}-${environmentName}`
55
- }
56
- }
@@ -1,34 +0,0 @@
1
- import {type CustomResourceOptions, output, type Output, Resource} from '@pulumi/pulumi'
2
- import {getProject, getServerlessInstance} from '@pulumi/mongodbatlas'
3
-
4
- export type MongoDBDefaultInstanceArgs = {
5
- organizationId: string
6
- projectId: string
7
- environmentName: string
8
- }
9
-
10
- export class MongoDBDefaultInstance extends Resource {
11
- readonly mongoProjectId: Output<string>
12
- readonly connectionString: Output<string>
13
- readonly databaseName: string
14
-
15
- constructor(args: MongoDBDefaultInstanceArgs, opts?: CustomResourceOptions) {
16
- const {organizationId, projectId, environmentName} = args
17
- super('mstuercke:mongodb:MongoDBDefaultInstance', organizationId, false, undefined, opts)
18
-
19
- const mongoProject = output(getProject({name: 'default'}))
20
-
21
- const mongoInstance = mongoProject.id.apply((mongoProjectId) =>
22
- output(
23
- getServerlessInstance({
24
- projectId: mongoProjectId,
25
- name: 'default',
26
- }),
27
- ),
28
- )
29
-
30
- this.mongoProjectId = mongoProject.id
31
- this.connectionString = mongoInstance.connectionStringsStandardSrv
32
- this.databaseName = `${projectId}-${environmentName}`
33
- }
34
- }
@@ -1,48 +0,0 @@
1
- import {type CustomResourceOptions, type Input, type Output, Resource} from '@pulumi/pulumi'
2
- import {RandomPassword} from '@pulumi/random'
3
- import {DatabaseUser} from '@pulumi/mongodbatlas'
4
-
5
- export type MongoDBUserArgs = {
6
- mongoProjectId: Input<string>
7
- databaseName: string
8
- projectId: string
9
- environmentName: string
10
- }
11
-
12
- export class MongoDBUser extends Resource {
13
- readonly username: string
14
- readonly password: Output<string>
15
-
16
- constructor(args: MongoDBUserArgs, opts?: CustomResourceOptions) {
17
- const {mongoProjectId, databaseName, projectId, environmentName} = args
18
- const username = `${projectId}-${environmentName}`
19
- super('mstuercke:mongodb:MongoDBUser', username, false, undefined, opts)
20
-
21
- const password = new RandomPassword(
22
- 'password',
23
- {
24
- length: 32,
25
- special: false,
26
- },
27
- {parent: this},
28
- )
29
-
30
- new DatabaseUser(
31
- 'user',
32
- {
33
- projectId: mongoProjectId,
34
- username,
35
- password: password.result,
36
- authDatabaseName: 'admin',
37
- roles: [
38
- {roleName: 'dbAdmin', databaseName},
39
- {roleName: 'readWrite', databaseName},
40
- ],
41
- },
42
- {parent: this},
43
- )
44
-
45
- this.username = username
46
- this.password = password.result
47
- }
48
- }
@@ -1,13 +0,0 @@
1
- import {MongoDBCustomInstance} from './MongoDBCustomInstance.ts'
2
- import {MongoDBDefaultInstance} from './MongoDBDefaultInstance.ts'
3
- import {MongoDBUser} from './MongoDBUser.ts'
4
-
5
- export * from './MongoDBCustomInstance.ts'
6
- export * from './MongoDBDefaultInstance.ts'
7
- export * from './MongoDBUser.ts'
8
-
9
- export const mongodb = {
10
- MongoDBCustomInstance,
11
- MongoDBDefaultInstance,
12
- MongoDBUser,
13
- }