-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues creating an Amazon Lambda function #255
Comments
Also, what's the difference between the server here and the one given by https://github.com/JetBrains/kotlin-web-demo? Edit: nevermind, I see now that kotlin-playground calls that the "old" server. |
Also, is |
Hey, thanks for the issue. Did u try the SAM to deploy the lambda? Could you please provide cloudwatch logs? |
For Kotless, yes, I need to write an instruction. Right now the project works with kotless. You just need to remove aws-serverless-container and rewrite the string boot main class. Should be like: import io.kotless.dsl.spring.Kotless
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import kotlin.reflect.KClass
@SpringBootApplication
class CompilerApplication : Kotless() {
override val bootKlass: KClass<*> = this::class
}
fun main(args: Array<String>) {
runApplication<CompilerApplication>(*args)
} |
I don't think I used SAM. I just did:
That API gateway had an invoke URL of https://ah41tetfai.execute-api.eu-west-2.amazonaws.com, so I tried calling https://ah41tetfai.execute-api.eu-west-2.amazonaws.com/versions and that's when I see the 500 error.
I don't see any logs at all in Cloudwatch when I call that URL, so it's possible I'm not even invoking the function? When I run a test event in I see some logs:
I'm happy to use SAM, but I haven't ever used that before so I don't know how to do it. |
OK so I tried using an Elastic Load Balancer instead of an API gateway as the trigger, and it started working. (I used the load balancer I created before to be a HTTPS reverse proxy in #257). Edit: Not it's not working. I just confused myself. Oh well I'll leave what I wrote before realizing this after the fold. I guess you can close this issue, however I propose expanding the lambda instructions to include a "quick-setup" guide for people who aren't experienced with this. Or maybe you could argue that's out of scope of this repository. I'm not sure. Here's what I would write (I need to test this and edit it): Quick startPrerequisitesYou have an AWS account Build the lambda function
Upload the function code to s3Go to https://s3.console.aws.amazon.com/s3.
Create the lambdaGo to https://console.aws.amazon.com/lambda/ and create function. Use the following settings:
Install the function codeClick on your new lambda function.
Add a triggerClick + Add Trigger, and choose Load Balancer. Where it prompts you to choose a load balancer, create a new one:
Click next, skip warning about security (we will worry about SSL later) Step 3: Choose default security group Step 4: Create a new target group, Target type = Lambda function. Leave health checks unchecked for now. Step 5: Register targets: Select your lambda function. Now find the load balancer you just created and find its DNS name, and call http:///version and you should get a response from the lambda function! Edit: as mentioned above, this doesn't actually work. I can't get it working. |
Hey, I will try to help you. Did u deploy the last master? Did u try to use Kotless? It is a nice tool. Try to use one. You can find docs here. Also, I have just tested the last master with Kotless and it works on my side. Also, I'm going to deploy the lambda like you this week. |
OK thanks for the help. I've managed to get it working with Docker on aws ECS instead of aws Lambda, so this isn't high priority for me (though Lambda feels more efficient somehow). I feel a bit embarrassed that maybe this isn't a real issue. It's not really in scope of On the other hand I think it is nice for repositories like this to have a quick-start guide for noobs. But I can see how it might be more efficient to just link a general aws Lambda tutorial. FWIW I think my problem is with wiring - i.e. making sure that I could get the request from my computer, to the EC2 Load Balancer, to the Lambda function. Something in the middle there was getting lost. |
By the way thanks for the help, and for creating this server. I now have some nice documentation going on in github pages. (Still a WIP: https://chriscoomber.github.io/manydice/) |
Hi there. I'm learning KMM and I have written a test project Kotlin library. I wanted to make a quick website which showed the documentation and also had a window for people to try out the library live. For this, I want to use something like the kotlin playground, with this as the backend. For the backend, I want to:
Add my library as a dependency this server (I think I did this well enough - I added mavenLocal() which I've installed my library to and I added my library as a dependency - 2 lines of build script total)
Create an AWS Lambda function so that my website (which doesn't exist yet) can make HTTP requests to this AWS function (via an AWS API Gateway).
I'm stuck on the latter. As an aside, it would be useful to have more documentation here for how I should configure my AWS function. For example, I think I needed to create a new AWS Lambda function (I did everything via the AWS website as the aws CLI wasn't working properly on my machine), using Java 8 runtime. Then I needed to upload the ZIP, which needs to be done by first creating an S3 bucket and uploading it to that. And then I need to add a trigger using AWS API Gateway, with HTTP rather than REST (right?), and then I wasn't sure about stages so I left that default. Also I wasn't sure about CORS so I checked that box because it sounded necessary. Maybe I'm a noob but not much of this was obvious.
Anyway, I've now created my Lambda function but when I run
curl -X GET https://dthvag45o1.execute-api.eu-west-2.amazonaws.com/versions
I get a 500 error:I have no way to debug this. I've no idea what I did wrong. The Lambda function's dashboard is registering that it saw an error. Although, I get the same error when putting any string instead of
versions
.Do you have any advice?
The text was updated successfully, but these errors were encountered: