Is there a way to set a role to an inline lambda f...
# aws
r
Is there a way to set a role to an inline lambda function to do stuff with the aws sdk?
Copy code
const endpoint = new awsx.apigateway.API(`service-api`, {
  routes: [
    // Serve static files from the `www` folder (using AWS S3)
    {
      path: "/",
      localPath: "www",
    },

    // Serve a simple REST API on `GET /name` (using AWS Lambda)
    {
      path: "/start",
      method: "GET",
      eventHandler: async (event) => {
        try {
          const ec2 = new aws.sdk.EC2();
          const myInstance = await server.id.get();
          const params = {
            InstanceIds: [myInstance],
          };
...
b
Not if you use inline lambdas like you are above, but if you have the the lambda in a separate function, you can apply a role to that and then point the eventHandler in the code above. Take a look at this section of the docs
r
Thanks I'll try it!
hey, that did the trick, thanks so much 🙂