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