@mstuercke/pulumi-modules 0.0.4 → 0.0.5
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/package.json +7 -7
- package/src/auth0/index.ts +2 -2
- package/src/domain/index.ts +2 -2
- package/src/iam/SimpleIamRolePolicy.ts +5 -6
- package/src/iam/SimpleIamRolePolicyConfig.ts +1 -1
- package/src/iam/index.ts +3 -3
- package/src/index.ts +19 -19
- package/src/lambda/NodeLambdaFunction.ts +4 -5
- package/src/lambda/index.ts +2 -2
- package/src/mongodb/MongoDBCustomInstance.ts +56 -0
- package/src/mongodb/MongoDBDefaultInstance.ts +34 -0
- package/src/mongodb/MongoDBUser.ts +48 -0
- package/src/mongodb/index.ts +9 -5
- package/src/rest/RestApi.ts +2 -1
- package/src/rest/index.ts +2 -2
- package/src/s3/index.ts +2 -2
- package/src/website/StaticWebsite.ts +18 -2
- package/src/website/index.ts +2 -2
- package/src/website/readFilesRecursive.ts +2 -2
- package/src/websocket/WebsocketApi.ts +1 -1
- package/src/websocket/index.ts +2 -2
- package/tsconfig.json +3 -16
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mstuercke/pulumi-modules",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"files": [
|
|
5
5
|
"src/**/!(*.test|*.fixture).ts",
|
|
6
6
|
"tsconfig.json",
|
|
7
7
|
"README.md"
|
|
8
8
|
],
|
|
9
|
-
"
|
|
10
|
-
"type": "
|
|
9
|
+
"exports": "./src/index.ts",
|
|
10
|
+
"type": "module",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"typeCheck": "tsc --noEmit",
|
|
13
13
|
"bump:major": "npm version major --git-tag-version false",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"release": "bun run --tsconfig-override ./tsconfig.scripts.json scripts/release.ts"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@pulumi/archive": "^0.
|
|
19
|
+
"@pulumi/archive": "^0.3.0",
|
|
20
20
|
"@pulumi/auth0": "^3.8.1",
|
|
21
21
|
"@pulumi/aws": "^6.56.1",
|
|
22
22
|
"@pulumi/mongodbatlas": "^3.20.2",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"@pulumi/random": "^4.16.7",
|
|
25
25
|
"@pulumiverse/sentry": "^0.0.9",
|
|
26
26
|
"@types/mime": "^3.0.4",
|
|
27
|
-
"glob": "
|
|
27
|
+
"glob": "11.0.1",
|
|
28
28
|
"mime": "^3.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@mstuercke/bun-utils": "7.0.6",
|
|
32
|
-
"@types/bun": "1.
|
|
33
|
-
"typescript": "5.7.
|
|
32
|
+
"@types/bun": "1.2.2",
|
|
33
|
+
"typescript": "5.7.3"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/auth0/index.ts
CHANGED
package/src/domain/index.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {iam} from '@pulumi/aws'
|
|
2
|
-
import type {SimpleIamRolePolicyConfig} from './SimpleIamRolePolicyConfig'
|
|
3
|
-
import type
|
|
4
|
-
import type {RolePolicyArgs} from '@pulumi/aws/iam'
|
|
5
|
-
import type {PolicyStatement} from '@pulumi/aws/iam/documents'
|
|
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'
|
|
6
5
|
|
|
7
6
|
export class SimpleIamRolePolicy extends iam.RolePolicy {
|
|
8
7
|
constructor(iamRoleId: string, config: SimpleIamRolePolicyConfig, opts?: CustomResourceOptions) {
|
|
@@ -19,7 +18,7 @@ export class SimpleIamRolePolicy extends iam.RolePolicy {
|
|
|
19
18
|
{
|
|
20
19
|
Action: ['dynamodb:*'],
|
|
21
20
|
Effect: 'Allow',
|
|
22
|
-
Resource: [`${
|
|
21
|
+
Resource: output(config.tableArn).apply((tableArn) => [`${tableArn}`, `${tableArn}/*`]),
|
|
23
22
|
},
|
|
24
23
|
]),
|
|
25
24
|
opts,
|
|
@@ -56,7 +55,7 @@ export class SimpleIamRolePolicy extends iam.RolePolicy {
|
|
|
56
55
|
{
|
|
57
56
|
Action: ['s3:*'],
|
|
58
57
|
Effect: 'Allow',
|
|
59
|
-
Resource: [`${
|
|
58
|
+
Resource: output(config.bucketArn).apply((bucketArn) => [`${bucketArn}`, `${bucketArn}/*`]),
|
|
60
59
|
},
|
|
61
60
|
]),
|
|
62
61
|
opts,
|
package/src/iam/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {SimpleIamRolePolicy} from './SimpleIamRolePolicy'
|
|
1
|
+
import {SimpleIamRolePolicy} from './SimpleIamRolePolicy.ts'
|
|
2
2
|
|
|
3
|
-
export * from './SimpleIamRolePolicy'
|
|
4
|
-
export * from './SimpleIamRolePolicyConfig'
|
|
3
|
+
export * from './SimpleIamRolePolicy.ts'
|
|
4
|
+
export * from './SimpleIamRolePolicyConfig.ts'
|
|
5
5
|
|
|
6
6
|
export const iam = {
|
|
7
7
|
SimpleIamRolePolicy,
|
package/src/index.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
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'
|
|
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
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'
|
|
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
20
|
|
|
21
21
|
export const mstuercke = {
|
|
22
22
|
auth0,
|
|
@@ -27,5 +27,5 @@ export const mstuercke = {
|
|
|
27
27
|
rest,
|
|
28
28
|
s3,
|
|
29
29
|
website,
|
|
30
|
-
websocket,
|
|
30
|
+
websocket: websocket,
|
|
31
31
|
}
|
|
@@ -2,9 +2,8 @@ import {iam, lambda} from '@pulumi/aws'
|
|
|
2
2
|
import {getFile} from '@pulumi/archive'
|
|
3
3
|
import {asset, type CustomResourceOptions, type Output, Resource} from '@pulumi/pulumi'
|
|
4
4
|
|
|
5
|
-
import type
|
|
6
|
-
import type {WithInputs} from './WithInputs'
|
|
7
|
-
import {mstuercke} from '../index'
|
|
5
|
+
import {SimpleIamRolePolicy, type SimpleIamRolePolicyConfig} from '../iam/index.ts'
|
|
6
|
+
import type {WithInputs} from './WithInputs.js'
|
|
8
7
|
|
|
9
8
|
export type NodeLambdaFunctionArgs<EnvironmentVariables> = {
|
|
10
9
|
name: string
|
|
@@ -60,7 +59,7 @@ export class NodeLambdaFunction<
|
|
|
60
59
|
)
|
|
61
60
|
|
|
62
61
|
role.id.apply((roleId) => {
|
|
63
|
-
new
|
|
62
|
+
new SimpleIamRolePolicy(
|
|
64
63
|
roleId,
|
|
65
64
|
{
|
|
66
65
|
type: 'custom',
|
|
@@ -77,7 +76,7 @@ export class NodeLambdaFunction<
|
|
|
77
76
|
)
|
|
78
77
|
|
|
79
78
|
for (const config of additionalIamRolePolicies) {
|
|
80
|
-
new
|
|
79
|
+
new SimpleIamRolePolicy(roleId, config, {parent: this})
|
|
81
80
|
}
|
|
82
81
|
})
|
|
83
82
|
|
package/src/lambda/index.ts
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
}
|
package/src/mongodb/index.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import {MongoDBCustomInstance} from './MongoDBCustomInstance.ts'
|
|
2
|
+
import {MongoDBDefaultInstance} from './MongoDBDefaultInstance.ts'
|
|
3
|
+
import {MongoDBUser} from './MongoDBUser.ts'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './MongoDBCustomInstance.ts'
|
|
6
|
+
export * from './MongoDBDefaultInstance.ts'
|
|
7
|
+
export * from './MongoDBUser.ts'
|
|
6
8
|
|
|
7
9
|
export const mongodb = {
|
|
8
|
-
|
|
10
|
+
MongoDBCustomInstance,
|
|
11
|
+
MongoDBDefaultInstance,
|
|
12
|
+
MongoDBUser,
|
|
9
13
|
}
|
package/src/rest/RestApi.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {apigateway, lambda} from '@pulumi/aws'
|
|
|
3
3
|
import type {CustomResourceOptions, Input} from '@pulumi/pulumi'
|
|
4
4
|
import {Record} from '@pulumi/aws/route53'
|
|
5
5
|
import {BasePathMapping, DomainName} from '@pulumi/aws/apigateway'
|
|
6
|
-
import type {NodeLambdaFunction} from '../lambda'
|
|
6
|
+
import type {NodeLambdaFunction} from '../lambda/index.ts'
|
|
7
7
|
|
|
8
8
|
export interface RestApiArgs {
|
|
9
9
|
name: string
|
|
@@ -180,6 +180,7 @@ export class RestApi extends aws.apigateway.RestApi {
|
|
|
180
180
|
restApi: this.id,
|
|
181
181
|
stageName: stageName,
|
|
182
182
|
deployment: deployment.id,
|
|
183
|
+
tags: {project: projectId},
|
|
183
184
|
},
|
|
184
185
|
{parent: deployment},
|
|
185
186
|
)
|
package/src/rest/index.ts
CHANGED
package/src/s3/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {type CustomResourceOptions, type Input, Resource} from '@pulumi/pulumi'
|
|
2
|
-
import {type PublicS3Bucket, s3} from '../s3'
|
|
2
|
+
import {type PublicS3Bucket, s3} from '../s3/index.ts'
|
|
3
3
|
import {BucketObject} from '@pulumi/aws/s3'
|
|
4
4
|
import {Distribution} from '@pulumi/aws/cloudfront'
|
|
5
5
|
import {Record} from '@pulumi/aws/route53'
|
|
6
|
-
import {readFilesRecursive} from './readFilesRecursive'
|
|
6
|
+
import {readFilesRecursive} from './readFilesRecursive.js'
|
|
7
7
|
|
|
8
8
|
export interface StaticWebsiteArgs {
|
|
9
9
|
projectId: string
|
|
@@ -92,6 +92,22 @@ export class StaticWebsite extends Resource {
|
|
|
92
92
|
defaultTtl: 0,
|
|
93
93
|
maxTtl: 0,
|
|
94
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
|
+
|
|
95
111
|
forwardedValues: {
|
|
96
112
|
queryString: false,
|
|
97
113
|
cookies: {
|
package/src/website/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@pulumi/aws/apigatewayv2'
|
|
12
12
|
import {Policy, Role} from '@pulumi/aws/iam'
|
|
13
13
|
import {Record} from '@pulumi/aws/route53'
|
|
14
|
-
import type {NodeLambdaFunction} from '../lambda'
|
|
14
|
+
import type {NodeLambdaFunction} from '../lambda/index.ts'
|
|
15
15
|
|
|
16
16
|
export interface WebsocketApiArgs {
|
|
17
17
|
name: string
|
package/src/websocket/index.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
"target": "ESNext",
|
|
6
|
-
"module": "CommonJS",
|
|
7
|
-
"moduleResolution": "node",
|
|
8
|
-
"sourceMap": true,
|
|
9
|
-
"experimentalDecorators": true,
|
|
10
|
-
"pretty": true,
|
|
11
|
-
"noFallthroughCasesInSwitch": true,
|
|
12
|
-
"noImplicitReturns": true,
|
|
13
|
-
"forceConsistentCasingInFileNames": true,
|
|
14
|
-
"skipLibCheck": true
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"src/index.ts"
|
|
2
|
+
"extends": "@mstuercke/typescript-config/pulumi/tsconfig.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"src",
|
|
18
5
|
]
|
|
19
6
|
}
|