https://pulumi.com logo
#aws
Title
# aws
r

refined-bear-62276

11/25/2020, 1:05 PM
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

brave-planet-10645

11/25/2020, 2:27 PM
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

refined-bear-62276

11/25/2020, 2:33 PM
Thanks I'll try it!
hey, that did the trick, thanks so much 🙂