Skip to content

Commit

Permalink
Force some bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpatto committed Sep 19, 2024
1 parent 1e2f8be commit f76e664
Show file tree
Hide file tree
Showing 9 changed files with 6,264 additions and 4,733 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"version": "0.0.0",
"description": "The root package of a mono repo for Steps S3 copy",
"packageManager": "pnpm@9.7.0",
"packageManager": "pnpm@9.10.0",
"scripts": {
"build": "pnpm --stream --filter \"./packages/**\" run build",
"watch": "pnpm --stream --filter \"./packages/**\" run build:watch",
Expand All @@ -19,7 +19,7 @@
"devDependencies": {
"@tsconfig/node18": "18.2.4",
"@types/node": "18.19.44",
"esbuild": "0.23.0",
"esbuild": "0.23.1",
"prettier": "3.3.3",
"ts-node": "10.9.2",
"typescript": "5.5.4"
Expand Down
2,046 changes: 1,136 additions & 910 deletions packages/steps-s3-copy/lambda/can-write-lambda/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"main": "can-write-lambda.ts",
"dependencies": {
"@aws-sdk/client-s3": "3.405.0",
"@aws-sdk/client-s3": "3.654.0",
"@types/aws-lambda": "8.10.93"
}
}
2,050 changes: 1,138 additions & 912 deletions packages/steps-s3-copy/lambda/summarise-copy-lambda/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "can-write-lambda",
"name": "summarise-copy-lambda",
"version": "1.0.0",
"main": "summarise-copy-lambda.ts",
"dependencies": {
"@aws-sdk/client-s3": "3.405.0",
"@aws-sdk/client-s3": "3.654.0",
"@types/aws-lambda": "8.10.93",
"csv-stringify": "6.4.4"
}
Expand Down
2,050 changes: 1,138 additions & 912 deletions packages/steps-s3-copy/lambda/thaw-objects-lambda/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"main": "thaw-objects-lambda.ts",
"dependencies": {
"@aws-sdk/client-s3": "3.405.0",
"@aws-sdk/client-s3": "3.654.0",
"@types/aws-lambda": "8.10.93"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Construct } from "constructs";
import { Role } from "aws-cdk-lib/aws-iam";
import { Duration } from "aws-cdk-lib";
import { LambdaInvoke } from "aws-cdk-lib/aws-stepfunctions-tasks";
import { Runtime } from "aws-cdk-lib/aws-lambda";
import { Architecture, Runtime } from "aws-cdk-lib/aws-lambda";
import { JsonPath } from "aws-cdk-lib/aws-stepfunctions";
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
import { join } from "node:path";
Expand Down Expand Up @@ -31,24 +31,26 @@ export class SummariseCopyLambdaStepConstruct extends Construct {
) {
super(scope, id);

const root = join(__dirname, "..", "..", "lambda", "summarise-copy-lambda");

const summariseCopyLambda = new NodejsFunction(
this,
"SummariseCopyFunction",
{
role: props.writerRole,
entry: join(
__dirname,
"..",
"..",
"lambda",
"summarise-copy-lambda",
"summarise-copy-lambda.ts",
),
entry: join(root, "summarise-copy-lambda.ts"),
depsLockFilePath: join(root, "package-lock.json"),
runtime: Runtime.NODEJS_20_X,
architecture: Architecture.ARM_64,
handler: "handler",
bundling: {
// we don't exactly need the performance benefits of minifying, and it is easier to debug without
minify: false,
// because we install node_modules we want to force the installation in a lambda compatible env
forceDockerBundling: true,
// and these are the modules we need to install
nodeModules: ["csv-stringify"],
platform: "arm",
},
environment: {
WORKING_BUCKET: props.workingBucket,
Expand All @@ -59,40 +61,6 @@ export class SummariseCopyLambdaStepConstruct extends Construct {
},
);

/* summariseCopyLambda.addToRolePolicy(
new PolicyStatement({
effect: Effect.ALLOW,
actions: ["s3:PutObject"],
resources: ["*"],
// yes - that's right - we want to give this lambda the ability to attempt the writes anywhere
// EXCEPT where we are deployed
// (under the assumption that buckets outside our account must be giving us explicit write permission,
// whilst within our account we get implicit access - in this case we don't want that ability)
conditions: props.allowWriteToThisAccount
? undefined
: {
StringNotEquals: {
"s3:ResourceAccount": [Stack.of(this).account],
},
},
}),
);
// we need to be able to read the results created by Steps that it placed
// in the working folder
summariseCopyLambda.addToRolePolicy(
new PolicyStatement({
effect: Effect.ALLOW,
actions: ["s3:*"],
resources: ["*"],
//[
//`arn:aws:s3:::${props.workingBucket}/${
// props.workingBucketPrefixKey ?? ""
//}*`,
//],
}),
); */

this.invocableLambda = new LambdaInvoke(this, `Summarise Copy Results`, {
lambdaFunction: summariseCopyLambda,
resultPath: JsonPath.DISCARD,
Expand Down
Loading

0 comments on commit f76e664

Please sign in to comment.