Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 16 2019 18:39

    carlosandrebp on master

    upload email icon (compare)

  • Jan 15 2019 14:03

    carlosandrebp on master

    Icons update (compare)

  • Nov 13 2018 16:54
    hassankhan commented #3
  • Nov 02 2018 15:10
    hassankhan commented #3
  • Nov 02 2018 15:10
    hassankhan commented #3
  • Nov 01 2018 23:19
    hassankhan commented #3
  • Oct 29 2018 16:32
    hassankhan commented #3
  • Oct 24 2018 14:38
    hassankhan opened #3
  • Aug 14 2018 23:50

    carlosandrebp on master

    updates animations (compare)

  • Jul 19 2018 16:34
    brianneisler closed #1
  • Jul 19 2018 16:34
    brianneisler commented #1
  • Jul 18 2018 16:36

    andrepiresbp on master

    Updates (compare)

  • Jul 18 2018 15:50

    andrepiresbp on master

    Update (compare)

  • Jul 09 2018 19:25
    gornostal commented #59
  • Jul 09 2018 19:12
    maheshmasale commented #59
  • May 24 2018 23:39
    DavidWells removed as member
  • Feb 13 2018 19:40
    ivan-myob commented #54
  • Feb 08 2018 08:48
    julien2x opened #62
  • Dec 22 2017 16:14
    awcheng opened #61
  • Oct 23 2017 19:12
    dluu2015 closed #60
Imran
@Imran99
Hey guys i've been using https://www.npmjs.com/package/serverless-pseudo-parameters to resolve AWS::AccountId but thats deprecated as apparently this is now supported in serverless framework directly. I can't seem to get this to work though and the documentation https://www.serverless.com/framework/docs/providers/aws/guide/variables#pseudo-parameters-reference only mentions using pseudo parameters in the resources section which is not the same as what the plugin offered. Any ideas if it is actually possible to now reference AWS::AccountId from anywhere in serverless.yml?
Ross Coundon
@rcoundon
Is there any way to access serverless CLI options like stage in serverless.ts ? Would be cool to apply some logic driven by things like stage and region #Serverless #typescript
Gareth McCumskey
@garethmcc
@rcoundon They should still be available as variables using ${} syntax.
Ross Coundon
@rcoundon

@rcoundon They should still be available as variables using ${} syntax.

They can be referenced inside the configuration using the likes of

stage: '${opt:stage, self:provider.stage}',

But what I'd like to do is to reference them outside of the configuration e.g.

import type { AWS } from '@serverless/typescript';
console.log('${opt:stage, self:provider.stage}');

const serverlessConfiguration: AWS = {
...
  provider: {
    name: 'aws',
    stage: 'dev',
    stackTags: {
      stage: '${opt:stage, self:provider.stage}',
    }
}
i.e. the console.log() of the stage
Gareth McCumskey
@garethmcc
Dont wrap them in ' ?
Try console.log(${opt}) and see what you get?
Ross Coundon
@rcoundon

Dont wrap them in ' ?

TypeScript won't compile then as there's no variable in scope with that name and even in JavaScript it becomes invalid syntax - i.e.

console.log(`${opt:stage}`); // can't have a colon in a variable name
Gareth McCumskey
@garethmcc
Try just opt to see what it has if anything. I am pretty sure the framework makes them aqvailable in the serverless.ts I just can't recall exactly how
Ross Coundon
@rcoundon
Yeah, unfortunately can't compile the TS with that, and using JS just throws the error:
ReferenceError: opt is not defined
Ross Coundon
@rcoundon
After some playing around, it looks like it can be done by importing the serverless instance itself:
const serverless = require('serverless');  // Haven't worked out why I can't use import here yet
const sls = new serverless();
console.log(sls.service.provider.stage); // prints 'dev'
Ross Coundon
@rcoundon
As a result of running
sls offline --s dev start
Ross Coundon
@rcoundon
I take that back, it always prints dev ...
Gareth McCumskey
@garethmcc
Can you use --stage instead?
dev is the default
and provider.stage will alway be thatr because that is the config value. opt.stage would be what is passed
Ross Coundon
@rcoundon
I'll investigate, I can see that in sls.config I can get hold of cliInputArgv: [ '--s', 'production', 'deploy' ], so could parse that out but I suspect the parsed command line must be in there somewhere. It's not possible to stringify the object due to lots of circular dependencies so I'll do some digging and report back. Thanks for the pointers
Ross Coundon
@rcoundon
Hmm, printing out all of the contents of the serverless object using flatted and the term production only occurs in terms of the command line arguments. There's no opt or options property in there anywhere
Ross Coundon
@rcoundon
Maybe there's a different object I need to get hold of?
Ross Coundon
@rcoundon

So, looking through source code of serverless led me to the processedInput variable.
Doing this

const serverless = require('serverless');

const sls = new serverless();
sls.init();
console.log(JSON.stringify(sls.processedInput, null, 2));

Produces

{
  "commands": [
    "offline",
    "start"
  ],
  "options": {
    "stage": "production"
  }
}

processedInput isn't marked as private so I guess this is 'safe'...

Ross Coundon
@rcoundon
Although, as it's JS and #/private proposal is at stage 3, I guess it could happen later
Ross Coundon
@rcoundon
So any other ideas, greatly appreciated (sorry to spam the channel!)
jugglingjsons
@jugglingjsons

Hey! Is there a way to keep deletionPolicy on an s3 bucket and dynamodb table and use the same buckets / s3 from old deployments on new stacks?
I want to use the same serverless.yml to deploy new stacks and redeploy stack using the previously retained s3 buckets / dynamodb tables.
I've set up the:

DeletionPolicy: Retain
but currently getting
An error occurred: xxxx - xx-xx-xx-xx already exists.
on redeployments

Vaidas Unchained
@codepreneur
does anyone know how I can add "Accept": "image/png" header to every single request that comes in through api gateway to my lambda?
Ross Coundon
@rcoundon
I'm not sure but as the lambda is handling an event and you want to do it for all requests, why can't it assume the header is there? Is the lambda being used for other event sources?
Abhinav Prakash
@abhinavsp0730
Hi @all. I'm very new to serverless. I've
tried to deploy my first express server to aws with serverless but I'm getting 502 gateway error. Would you Folks please help me🥺.
'''
Abhinav Prakash
@abhinavsp0730
Below is my app.js code

const serverless = require('serverless-http');
const express = require("express");
const qs = require("qs");
const bodyParser = require("body-parser");
const axios = require("axios");

const app = express();

//app.use(
//cors({
//origin: "https://xxx",
//})
//);
//
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(bodyParser.text());
app.use(bodyParser.raw());

// let corsOptions = {
// origin: "https://xxx",
// // allowedHeaders: [
// // "Content-Type",
// // "Authorization",
// // "Content-Length",
// // "X-Requested-With",
// // "Accept",
// // ],
// methods: ["GET", "PUT", "POST", "DELETE", "OPTIONS"],
// optionsSuccessStatus: 200, // some legacy browsers (IE11, various SmartTVs) choke on 204
// };

// // app.use(cors(corsOptions));

// const corsm = (req, res, next) => {
// res.header("Access-Control-Allow-Origin", "*");
// res.header("Access-Control-Allow-Methods", "GET, POST");
// res.header(
// "Access-Control-Allow-Headers",
// "Origin, X-Requested-With, Content-Type, Accept, Authorization"
// );
// next();
// };

// app.use(function (req, res, next) {
// res.setHeader(
// "Access-Control-Allow-Origin",
// "xxx"
// ); // update to match the domain you will make the request from
// res.setHeader(
// "Access-Control-Allow-Headers",
// "Origin, X-Requested-With, Content-Type, Accept"
// );
// next();
// });

// app.options(function (req, res, next) {
// res.setHeader(
// "Access-Control-Allow-Origin",
// "xxxx"
// ); // update to match the domain you will make the request from
// res.setHeader(
// "Access-Control-Allow-Headers",
// "Origin, X-Requested-With, Content-Type, Accept"
// );
// next();
// });

app.post("/punctuate", async (req, res) => {
console.log("called");
let { text } = req.body;

text = text.replace(/\b((Applause)|(Laughter)|(thank you))\b/g, match => "");

text = text.replace(/[()|`|-|``|'']/g, "");

text = text.replace(/\s+/g, " ").trim();
try {
    const data = await axios({
        method: "post",
        url: "https://xxxx",
        data: qs.stringify({ text }),
        headers: {
            "content-type": "application/x-www-form-urlencoded;charset=utf-8",
            "Access-Control-Allow-Origin": "*",
        },
    });

    res.status(200).json({ text: JSON.stringify(data.data) });
} catch (error) {
    console.log(error.response);
    res.json({ text: "" });
}

});

app.post("/summary", async (req, res) => {
let talk = req.body;

const result = await axios({
    url: "https://xxxx",
    method: "post",
    headers: {
        "Content-Type": "text/plain",
    },
    data: talk,
});

res.status(200).send(result.data.summary);

});

// app.listen(8080, () => {
// console.log("server started 🚀,port 8080");
// });
module.exports.handler = serverless(app);

Ross Coundon
@rcoundon

Below is my app.js code

Hi - it's really hard to follow that as it's not formatted properly and there's lots that's commented out. It might be more readable if you set it up as a gist or codepen, or similar and link to it so we can help

Abhinav Prakash
@abhinavsp0730
@rcoundon Thanks ross. It's working now . But I'm able to do a post request using a curl command. But when I'm testing the API with fetch I'm getting cors error(CORS Missing Allow origin). But I haven't enabled cors while deploying in Aws Api gateway and in aws lamba also?
Chester O'Neill
@ThrowsException
Ive been looking into ways to bundle a serverless node application. I see serverless-webpack has the option for includeModules but is there a reason that you wouldn't just want webpack to bundle/treeshake everything for you and just output a single file?
epanfile
@epanfile
anyone know of instructions on how to debug the serverless framework code? more specifically, I am interested in extending the amplify-appsync-simulator plugin. How can I debug the code I am writing in this plugin?
Himanshu Joshi
@himharsh1997
Error: Body must be a string. Received: undefined.
getting this error on doing setup of aws appsync in serverless
Ross Coundon
@rcoundon

@rcoundon Thanks ross. It's working now . But I'm able to do a post request using a curl command. But when I'm testing the API with fetch I'm getting cors error(CORS Missing Allow origin). But I haven't enabled cors while deploying in Aws Api gateway and in aws lamba also?

Hi - you can specify cors on the http event:

    events:
      - http:
          path: somepath
          method: post
          cors: true

But you also need to return the necessary CORS headers from your lambda function.
For example, you could define a function to add the necessary headers to your returned objects something like

export function addCorsHeaders(response: APIGatewayProxyResult): APIGatewayProxyResult {
  if (!response.headers) {
    response.headers = {};
  }
  response.headers['Access-Control-Allow-Headers'] = 'Content-Type';
  response.headers['Access-Control-Allow-Origin'] = '*';
  response.headers['Access-Control-Allow-Methods'] = 'OPTIONS,POST,GET,PATCH,PUT,DELETE';

  return response;
}

Then you'd use it like:

const response = {
        statusCode: 200,
        body: JSON.stringify({
          message: 'some data',
        }),
      };
return addCorsHeaders(response);
Ross Coundon
@rcoundon

Ive been looking into ways to bundle a serverless node application. I see serverless-webpack has the option for includeModules but is there a reason that you wouldn't just want webpack to bundle/treeshake everything for you and just output a single file?

includeModules just gives you some options around including/excluding certain packages. For example, you might use something that is OS specific like sharp for local testing but not want this bundled in the package, so you can then use includeModules/forceExclude with sharp. Also, if you wanted to be specific about what to include you can use forceInclude, maybe you might want to do that with aws-sdk rather than use the version that lambda containers automatically include

ค๓เՇ
@amitizle_twitter

Hello, can someone please advise if the following makes sense?

functions:
  myCloudWatch:
    handler: myCloudWatch.handler
    events:
      - cloudwatchEvent:
          event:
            arn: "arn:aws:events:us-east-1:123456789012:rule/MyScheduledRule"
            source:
              - 'aws.events'
            detail-type:
              - 'Scheduled Event'

Generally I want to grant the λ function with a permission to be invoked by some scheduled rules, which are dynamic and therefore cannot be defined in the configuration yaml.
Thanks

nbouliol
@nbouliol
Hello, does anyone have a working example of deploying a lambda in a vpc to have a static ip ?
clmn
@JacksonGariety
I put cors: true in the function config in my serverless.yaml, but the browser still complains that the response to the preflight request "does not have HTTP ok status."
clmn
@JacksonGariety
I tried sending an OPTIONS request with curl and I got "internal server error"
Gareth McCumskey
@garethmcc
@JacksonGariety Can you share your serverless.yml config?
John Mikel Regida
@johnmikel
Hi guys, I'm trying to deploy nextjs in serverless using the plugin and I am getting a weird error - ReferenceError: window is not defined. Does anyone know where to start in solving this?
John Mikel Regida
@johnmikel
solved this using nextjs' dynamic imports
Yusuf Kanchwala
@kanchwala-yusuf
Hi Guys,
Can anyone please let me know if Azure Event Grid is supported as an event source in the serverless framework?
Manpreet Singh
@manpoffc
Hi Guys, I'm new here. Looking forward to contributing.
Alexandre Lemaire
@Saeven
Hey guys! Quick new-to-this question for you. Am using serverless through bref.sh; serverless deploy is failing with s3:CreateBucket Access Denied; can I specify the bucket that gets used somehow, such that the bucket can be created beforehand? For policy reasons (we work in a highly regulated industry), we can't allow auto-creation in access keys that are available to devs.
Kevin Piazzoli Felix Perez
@kevin4dhd
Hello guys, I hope you have a good day, my question is the following, as I create more tables with the aws-dynamodb component, if someone could give me the answer I would be very grateful, I have been stuck for several days.
Aws-dynamodb link: https://github.com/serverless-components/aws-dynamodb
Ross Coundon
@rcoundon
@JacksonGariety you need to return the necessary headers from your lambda too
r_mohan
@r_mohan_twitter
How versatile is the VTL in the gateway ? Can I populate a error JSON and return 400 when validation fails ? It should all happen within the VTL.