1

Has anyone experienced the above issue with the latest CloudFormation template and the latest release bundle? (lambda.zip)

The bundle includes:

index.js lambda-handler.js node_modules proxy-file.js server.js

CloudFormation configures:

API Gateway Lambda Function CloudFront Distribution

https://github.com/humanmade/tachyon

To me this indicates the object doesn't exist. However, it does and numerous tests can confirm the object is present and publicly available. If I call the api gateway directly and pass the arguments the lambda throws no errors, however, via CloudFront - its almost like its transforming the requested url and breaking the request?

https://my.custom.domain.co.uk/image.jpeg?resize=100,100 - this goes via the CloudFront distribution but the Lambda errors that no such key exists. The image is definitely reachable via the domain name and the path to the image as it loads in the browser without issue. However, passing the resize args it seems to break the function.

{
"errorMessage": "The specified key does not exist.",
"errorType": "NoSuchKey",
"stackTrace": [
"Request.extractError (/var/runtime/node_modules/aws-sdk/lib/services/s3.js:585:35)",
"Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)",
"Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)",
"Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)",
"Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
"AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
"/var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
"Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
"Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)",
"Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18)"
]
}
  • Using the provided CloudFormation template
  • Using the provided Tachyon code
  • One bucket for the Tachyon code
  • One bucket for the images - publicly accessible
  • Lambda variables provided for bucket name and region as per guidelines
  • DNS Cname pointing the domain at the CloudFront distribution

To me this seems to be an issue with the CloudFront configuration

"errorMessage": "The specified key does not exist.",
"errorType": "NoSuchKey",
"stackTrace": [
"Request.extractError (/var/runtime/node_modules/aws-sdk/lib/services/s3.js:585:35)",
"Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)",
"Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)",
"Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)",
"Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
"AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
"/var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
"Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
"Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)",
"Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18)"
]
}

Expected outcome is - https://my.custom.domain.co.uk/image.jpeg?resize=100,100 returns the resized image to the browser.

Actual outcome - the Lambda errors with no such key from the aws-sdk

Any guidance would be greatly appreciated.

Thanks

JoshW
  • 51
  • 1
  • 9
  • How did you format your reference to the S3 bucket? – Yann Stoneman Aug 17 '19 at 00:20
  • So the bucket is referenced using environment variables on the Lambda (as per the Tachyon docs) S3_BUCKET (bucketname) and S3_REGION (us-east-1) - I then just have a sample image sat in the root of the bucket which I reference in the url. – JoshW Aug 17 '19 at 09:04
  • "If I call the api gateway directly and pass the arguments the lambda throws no errors" If it's already working by just using the API Gateway endpoint, then why not just use that for your project? I'm not familiar with Tachyon, but I do know that CloudFront is already used under-the-hood by default with API Gateway endpoints: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-endpoint-types.html – Yann Stoneman Aug 17 '19 at 22:14

1 Answers1

0

cfn-lint outputs:

E0000 Duplicate resource found "Handler" (line 162)
cloudformation-template.json:162:9

According to the AWS::Lambda::Function docs, this resource type should have one Handler property. Did you mean to specify multiple Handler properties for this resource?

Pat Myron
  • 4,437
  • 2
  • 20
  • 39
  • Thanks for highlighting this - the CloudFormation template is from the Tachyon repo - but yes, the only handler visible in the Lambda console is the lambda-handler - but I guess this references the index.js file? which looks like it handles the Tachyon operations.. – JoshW Aug 17 '19 at 09:11