Skip to content

Commit

Permalink
Fix aws
Browse files Browse the repository at this point in the history
  • Loading branch information
AWare committed Oct 30, 2019
1 parent 00b1d2f commit 0ef041f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 43 deletions.
75 changes: 33 additions & 42 deletions projects/aws/lib/constructs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,39 @@ export const taskLambda = (
environment?: { [key: string]: string },
overrides?: Partial<FunctionProps>,
) => {
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)
Expand All @@ -93,13 +90,7 @@ export const task = (
environment?: { [key: string]: string },
overrides?: Partial<FunctionProps>,
) => {
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),
Expand Down
2 changes: 1 addition & 1 deletion projects/aws/lib/step-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 0ef041f

Please sign in to comment.