From 0ef041fc8eb6abc85d5a25504d59ab337a5a6081 Mon Sep 17 00:00:00 2001 From: Alex Ware Date: Tue, 29 Oct 2019 16:45:29 +0000 Subject: [PATCH] Fix aws --- projects/aws/lib/constructs.ts | 75 ++++++++++++++----------------- projects/aws/lib/step-function.ts | 2 +- 2 files changed, 34 insertions(+), 43 deletions(-) diff --git a/projects/aws/lib/constructs.ts b/projects/aws/lib/constructs.ts index 3f9d52643a..5e6cb5ac56 100644 --- a/projects/aws/lib/constructs.ts +++ b/projects/aws/lib/constructs.ts @@ -43,42 +43,39 @@ export const taskLambda = ( environment?: { [key: string]: string }, overrides?: Partial, ) => { - const fn = new lambda.Function( - scope, - `EditionsArchiver${toTitleCase(name)}`, - { - functionName: `editions-archiver-stepmachine-${name}-${stage}`, - runtime: lambda.Runtime.NODEJS_10_X, - timeout: Duration.minutes(5), - memorySize: 1500, - code: Code.bucket( - deployBucket, - `${stack}/${stage}/archiver/archiver.zip`, - ), - handler: `index.${name}`, - environment: { - ...environment, - stage: stage, - bucket: outputBucket.bucketName, - topic: frontsTopicArn, - role: frontsTopicRole.roleArn, - }, - initialPolicy: [ - new iam.PolicyStatement({ - actions: ['*'], - resources: [ - outputBucket.arnForObjects('*'), - outputBucket.bucketArn, - ], - }), - new iam.PolicyStatement({ - actions: ['sts:AssumeRole'], - resources: [frontsTopicRole.roleArn], - }), - ], - ...overrides, + const lambdaName = `EditionsArchiver${toTitleCase(name)}` + const fn = new lambda.Function(scope, lambdaName, { + functionName: `editions-archiver-stepmachine-${name}-${stage}`, + runtime: lambda.Runtime.NODEJS_10_X, + timeout: Duration.minutes(5), + memorySize: 1500, + code: Code.bucket( + deployBucket, + `${stack}/${stage}/archiver/archiver.zip`, + ), + handler: `index.${name}`, + environment: { + ...environment, + stage: stage, + bucket: outputBucket.bucketName, + topic: frontsTopicArn, + role: frontsTopicRole.roleArn, }, - ) + initialPolicy: [ + new iam.PolicyStatement({ + actions: ['*'], + resources: [ + outputBucket.arnForObjects('*'), + outputBucket.bucketArn, + ], + }), + new iam.PolicyStatement({ + actions: ['sts:AssumeRole'], + resources: [frontsTopicRole.roleArn], + }), + ], + ...overrides, + }) Tag.add(fn, 'App', `editions-archiver-${name}`) Tag.add(fn, 'Stage', stage) Tag.add(fn, 'Stack', stack) @@ -93,13 +90,7 @@ export const task = ( environment?: { [key: string]: string }, overrides?: Partial, ) => { - const lambda = taskLambda( - scope, - 'front', - lambdaParams, - environment, - overrides, - ) + const lambda = taskLambda(scope, name, lambdaParams, environment, overrides) const task = new sfn.Task(scope, [name, desc].join(': '), { task: new tasks.InvokeFunction(lambda), diff --git a/projects/aws/lib/step-function.ts b/projects/aws/lib/step-function.ts index 2af5e564c3..717a40a595 100644 --- a/projects/aws/lib/step-function.ts +++ b/projects/aws/lib/step-function.ts @@ -36,7 +36,7 @@ export const archiverStepFunction = ( backend: backendURL, }) - const frontMap = new sfn.Map(scope, 'Map Fronts', { + const frontMap = new sfn.Map(scope, 'EditionsArchiverFrontMap', { inputPath: '$.', itemsPath: '$.fronts', parameters: {