serverlesspub / imagemagick-aws-lambda-2

ImageMagick for AWS Lambda 2 runtimes
https://serverless.pub
Other
259 stars 163 forks source link

update example to include AWS-CDK usage #19

Open nexus-uw opened 4 years ago

nexus-uw commented 4 years ago

hi,

Im not sure where this could go within the existing documentation, so I thought I could just quickly dump it into an issue (feel free to close it)

I had some trouble getting imagemagick-aws-lambda-2 to work with AWS-CDK the other night, so I thought I would share how I got it to work

const imageMagick = new CfnApplication(scope, 'imageMagick', {
      location: {
        applicationId: 'arn:aws:serverlessrepo:us-east-1:145266761615:applications/image-magick-lambda-layer',
        semanticVersion: '1.0.0'
      }
    })

    const lambdaFn = new lambda.Function(this, 'myLambda', {
  ...
      layers: [
        lambda.LayerVersion.fromLayerVersionArn(this, 'imageLayer', imageMagick.getAtt('Outputs.LayerVersion').toString())
      ]
    })
aeksco commented 4 years ago

:+1: definitely worth adding this to the README.md - thanks for sharing @nexus-uw!