@mstuercke/pulumi-modules 0.0.5 → 0.0.7
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 +4 -4
- package/src/auth0/Auth0.ts +0 -162
- package/src/auth0/index.ts +0 -7
- package/src/domain/getDomain.ts +0 -32
- package/src/domain/index.ts +0 -7
- package/src/iam/SimpleIamRolePolicy.ts +0 -164
- package/src/iam/SimpleIamRolePolicyConfig.ts +0 -75
- package/src/iam/index.ts +0 -8
- package/src/index.ts +0 -31
- package/src/lambda/NodeLambdaFunction.ts +0 -119
- package/src/lambda/WithInputs.ts +0 -5
- package/src/lambda/index.ts +0 -7
- package/src/mongodb/MongoDB.ts +0 -86
- package/src/mongodb/MongoDBCustomInstance.ts +0 -56
- package/src/mongodb/MongoDBDefaultInstance.ts +0 -34
- package/src/mongodb/MongoDBUser.ts +0 -48
- package/src/mongodb/index.ts +0 -13
- package/src/rest/RestApi.ts +0 -227
- package/src/rest/index.ts +0 -7
- package/src/s3/PublicS3Bucket.ts +0 -92
- package/src/s3/index.ts +0 -7
- package/src/website/StaticWebsite.ts +0 -175
- package/src/website/index.ts +0 -7
- package/src/website/readFilesRecursive.ts +0 -33
- package/src/websocket/WebsocketApi.ts +0 -219
- package/src/websocket/index.ts +0 -7
- package/tsconfig.json +0 -6
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mstuercke/pulumi-modules",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"files": [
|
|
5
|
-
"
|
|
6
|
-
"tsconfig.json",
|
|
5
|
+
"dist/**/!(*.test|*.fixture)(.d.ts|.js)",
|
|
7
6
|
"README.md"
|
|
8
7
|
],
|
|
9
|
-
"exports": "./
|
|
8
|
+
"exports": "./dist/index.js",
|
|
10
9
|
"type": "module",
|
|
11
10
|
"scripts": {
|
|
12
11
|
"typeCheck": "tsc --noEmit",
|
|
12
|
+
"build": "tsc",
|
|
13
13
|
"bump:major": "npm version major --git-tag-version false",
|
|
14
14
|
"bump:minor": "npm version minor --git-tag-version false",
|
|
15
15
|
"bump:patch": "npm version patch --git-tag-version false",
|
package/src/auth0/Auth0.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import {type CustomResourceOptions, type Output, Resource} from '@pulumi/pulumi'
|
|
2
|
-
import {Client, ClientCredentials, Connection, ConnectionClient, Provider, Tenant, User} from '@pulumi/auth0'
|
|
3
|
-
|
|
4
|
-
export type Auth0Domain = `${string}.auth0.com`
|
|
5
|
-
export type Auth0URL = `http://${string}` | `https://${string}`
|
|
6
|
-
|
|
7
|
-
export interface Auth0User {
|
|
8
|
-
name: string
|
|
9
|
-
email: string
|
|
10
|
-
password: string
|
|
11
|
-
emailVerified: boolean
|
|
12
|
-
appMetadata?: Record<string, unknown>
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface Auth0Args {
|
|
16
|
-
projectId: string
|
|
17
|
-
environmentName: string
|
|
18
|
-
tenantDisplayName: string
|
|
19
|
-
clientDisplayName: string
|
|
20
|
-
domain: Auth0Domain
|
|
21
|
-
m2mClientId: string
|
|
22
|
-
allowedUrls: Auth0URL[]
|
|
23
|
-
allowedLoginCallbackUrls?: Auth0URL[]
|
|
24
|
-
allowedLogoutCallbackUrls?: Auth0URL[]
|
|
25
|
-
nativeAppId?: `com.${string}`
|
|
26
|
-
defaultUsers?: Auth0User[]
|
|
27
|
-
disableSignup?: boolean
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class Auth0 extends Resource {
|
|
31
|
-
domain: string
|
|
32
|
-
clientId: Output<string>
|
|
33
|
-
|
|
34
|
-
constructor(id: string, args: Auth0Args, opts?: CustomResourceOptions) {
|
|
35
|
-
super('mstuercke:auth0:Auth0', id, false, undefined, opts)
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
projectId,
|
|
39
|
-
environmentName,
|
|
40
|
-
tenantDisplayName,
|
|
41
|
-
clientDisplayName,
|
|
42
|
-
domain,
|
|
43
|
-
m2mClientId,
|
|
44
|
-
allowedUrls,
|
|
45
|
-
allowedLoginCallbackUrls,
|
|
46
|
-
allowedLogoutCallbackUrls,
|
|
47
|
-
nativeAppId,
|
|
48
|
-
defaultUsers = [],
|
|
49
|
-
disableSignup = false,
|
|
50
|
-
} = args
|
|
51
|
-
|
|
52
|
-
new Provider('provider', {}, {parent: this})
|
|
53
|
-
|
|
54
|
-
new Tenant(
|
|
55
|
-
'tenant',
|
|
56
|
-
{
|
|
57
|
-
friendlyName: tenantDisplayName,
|
|
58
|
-
flags: {
|
|
59
|
-
enableClientConnections: false,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{parent: this},
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
const nativeAppCallbackUrls = nativeAppId
|
|
66
|
-
? [
|
|
67
|
-
`${nativeAppId}.auth0://${domain}/ios/${nativeAppId}/callback`,
|
|
68
|
-
`${nativeAppId}.auth0://${domain}/android/${nativeAppId}/callback`,
|
|
69
|
-
]
|
|
70
|
-
: []
|
|
71
|
-
const client = new Client(
|
|
72
|
-
'client',
|
|
73
|
-
{
|
|
74
|
-
name: clientDisplayName,
|
|
75
|
-
appType: 'spa',
|
|
76
|
-
callbacks: [...(allowedLoginCallbackUrls || allowedUrls), ...nativeAppCallbackUrls],
|
|
77
|
-
webOrigins: allowedUrls,
|
|
78
|
-
allowedLogoutUrls: [...(allowedLogoutCallbackUrls || allowedUrls), ...nativeAppCallbackUrls],
|
|
79
|
-
jwtConfiguration: {
|
|
80
|
-
alg: 'RS256',
|
|
81
|
-
},
|
|
82
|
-
addons: {},
|
|
83
|
-
},
|
|
84
|
-
{parent: this},
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
const connection = new Connection(
|
|
88
|
-
'password-authentication',
|
|
89
|
-
{
|
|
90
|
-
name: `${projectId}-${environmentName}`,
|
|
91
|
-
strategy: 'auth0',
|
|
92
|
-
options: {
|
|
93
|
-
disableSignup: disableSignup,
|
|
94
|
-
bruteForceProtection: true,
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
{parent: this},
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
const m2mClientConnection = new ConnectionClient(
|
|
101
|
-
'password-authentication-m2m-client',
|
|
102
|
-
{
|
|
103
|
-
clientId: m2mClientId,
|
|
104
|
-
connectionId: connection.id,
|
|
105
|
-
},
|
|
106
|
-
{parent: client},
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
const clientConnection = new ConnectionClient(
|
|
110
|
-
'password-authentication-client',
|
|
111
|
-
{
|
|
112
|
-
clientId: client.id,
|
|
113
|
-
connectionId: connection.id,
|
|
114
|
-
},
|
|
115
|
-
{parent: client},
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
// TODO: Implement disabling of google-oauth2 (If possible, also disable "Username-Password-Authentication")
|
|
119
|
-
// // disable google-oauth2 on all clients
|
|
120
|
-
// const googleOauth2Connection = output(getConnection({name: 'google-oauth2'}))
|
|
121
|
-
// new ConnectionClients(
|
|
122
|
-
// 'google-oauth2-clients',
|
|
123
|
-
// {
|
|
124
|
-
// connectionId: googleOauth2Connection.id,
|
|
125
|
-
// enabledClients: [],
|
|
126
|
-
// },
|
|
127
|
-
// {parent: client, dependsOn: [client]},
|
|
128
|
-
// )
|
|
129
|
-
|
|
130
|
-
new ClientCredentials(
|
|
131
|
-
'credentials',
|
|
132
|
-
{
|
|
133
|
-
clientId: client.id,
|
|
134
|
-
authenticationMethod: 'none',
|
|
135
|
-
},
|
|
136
|
-
{parent: this},
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
for (const defaultUser of defaultUsers) {
|
|
140
|
-
const {name, email, emailVerified, password, appMetadata} = defaultUser
|
|
141
|
-
|
|
142
|
-
new User(
|
|
143
|
-
`default-user-${defaultUser.email}`,
|
|
144
|
-
{
|
|
145
|
-
connectionName: connection.name,
|
|
146
|
-
name: name,
|
|
147
|
-
email: email,
|
|
148
|
-
emailVerified: emailVerified,
|
|
149
|
-
password: password,
|
|
150
|
-
appMetadata: appMetadata ? JSON.stringify(appMetadata) : undefined,
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
dependsOn: [m2mClientConnection, clientConnection],
|
|
154
|
-
parent: connection,
|
|
155
|
-
},
|
|
156
|
-
)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
this.domain = domain
|
|
160
|
-
this.clientId = client.id
|
|
161
|
-
}
|
|
162
|
-
}
|
package/src/auth0/index.ts
DELETED
package/src/domain/getDomain.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {acm, type Provider, route53} from '@pulumi/aws'
|
|
2
|
-
|
|
3
|
-
export interface DataDomainOptions {
|
|
4
|
-
usEast1Provider: Provider
|
|
5
|
-
name: `${string}.${string}`
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type DomainResult = {
|
|
9
|
-
name: string
|
|
10
|
-
zoneId: string
|
|
11
|
-
nameServers: string[]
|
|
12
|
-
usEast1CertificateArn: string
|
|
13
|
-
euCentral1CertificateArn: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const getDomain = async (options: DataDomainOptions): Promise<DomainResult> => {
|
|
17
|
-
const {usEast1Provider, name} = options
|
|
18
|
-
|
|
19
|
-
const zone = await route53.getZone({name})
|
|
20
|
-
|
|
21
|
-
const euCentral1Certificate = await acm.getCertificate({domain: name})
|
|
22
|
-
|
|
23
|
-
const usEast1Certificate = await acm.getCertificate({domain: name}, {provider: usEast1Provider})
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
name: zone.name,
|
|
27
|
-
zoneId: zone.zoneId,
|
|
28
|
-
nameServers: zone.nameServers,
|
|
29
|
-
usEast1CertificateArn: usEast1Certificate.arn,
|
|
30
|
-
euCentral1CertificateArn: euCentral1Certificate.arn,
|
|
31
|
-
}
|
|
32
|
-
}
|
package/src/domain/index.ts
DELETED
|
@@ -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
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
|
-
}
|
package/src/lambda/WithInputs.ts
DELETED