Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use esbuild for the provider #35

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions cdkv1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as cfn from '@aws-cdk/aws-cloudformation';
import * as iam from '@aws-cdk/aws-iam';
import * as lambdaNodejs from '@aws-cdk/aws-lambda-nodejs';
import * as lambda from '@aws-cdk/aws-lambda';
import * as cdk from '@aws-cdk/core';
import * as customResource from '@aws-cdk/custom-resources';
Expand All @@ -22,26 +21,18 @@ export class SesSmtpCredentialsProvider extends cdk.Construct {
constructor(scope: cdk.Construct, id: string) {
super(scope, id);
this.provider = new customResource.Provider(this, 'ses-smtp-credentials-provider', {
onEventHandler: new lambdaNodejs.NodejsFunction(this, 'ses-smtp-credentials-event', {
entry: path.join(__dirname, 'provider', 'main.ts'),
projectRoot: path.join(__dirname, 'provider'),
depsLockFilePath: path.join(__dirname, 'provider', 'package-lock.json'),
onEventHandler: new lambda.Function(this, 'ses-smtp-credentials-event', {
code: lambda.Code.fromAsset(path.join(__dirname, 'provider')),
runtime: lambda.Runtime.NODEJS_14_X,
// To handle parcel-based versions of NodejsFunction
nodeModules: ['utf8', 'aws-sdk'],
// To handle esbuild-based versions of NodejsFunction
bundling: {
externalModules: ['utf8', 'aws-sdk'],
},
handler: 'onEvent',
handler: 'main.onEvent',
timeout: cdk.Duration.minutes(5),
initialPolicy: [
new iam.PolicyStatement({
resources: ['*'],
actions: ['iam:CreateUser', 'iam:PutUserPolicy', 'iam:CreateAccessKey', 'iam:DeleteUser', 'iam:DeleteUserPolicy', 'iam:DeleteAccessKey'],
}),
],
} as lambdaNodejs.NodejsFunctionProps),
}),
});
}
}
Expand Down
17 changes: 4 additions & 13 deletions cdkv2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as iam from 'aws-cdk-lib/aws-iam';
import * as lambdaNodejs from 'aws-cdk-lib/aws-lambda-nodejs';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as cdk from 'aws-cdk-lib';
import * as customResource from 'aws-cdk-lib/custom-resources';
Expand All @@ -22,26 +21,18 @@ export class SesSmtpCredentialsProvider extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
this.provider = new customResource.Provider(this, 'ses-smtp-credentials-provider', {
onEventHandler: new lambdaNodejs.NodejsFunction(this, 'ses-smtp-credentials-event', {
entry: path.join(__dirname, 'provider', 'main.ts'),
projectRoot: path.join(__dirname, 'provider'),
depsLockFilePath: path.join(__dirname, 'provider', 'package-lock.json'),
onEventHandler: new lambda.Function(this, 'ses-smtp-credentials-event', {
code: lambda.Code.fromAsset(path.join(__dirname, 'provider')),
runtime: lambda.Runtime.NODEJS_14_X,
// To handle parcel-based versions of NodejsFunction
nodeModules: ['utf8', 'aws-sdk'],
// To handle esbuild-based versions of NodejsFunction
bundling: {
externalModules: ['utf8', 'aws-sdk'],
},
handler: 'onEvent',
handler: 'main.onEvent',
timeout: cdk.Duration.minutes(5),
initialPolicy: [
new iam.PolicyStatement({
resources: ['*'],
actions: ['iam:CreateUser', 'iam:PutUserPolicy', 'iam:CreateAccessKey', 'iam:DeleteUser', 'iam:DeleteUserPolicy', 'iam:DeleteAccessKey'],
}),
],
} as lambdaNodejs.NodejsFunctionProps),
}),
});
}
}
Expand Down
Loading