scaleway / serverless-scaleway-functions

Plugin for Serverless Framework to allow users to deploy their serverless applications on Scaleway Functions
MIT License
78 stars 25 forks source link

serverless.ts not supported? #155

Open sanderkooger opened 1 year ago

sanderkooger commented 1 year ago

I have created a repo with a serverless.ts instead of a serverless.yml

import ScalewayServerlessConfiguration from './src/types/ScalewayServerless'

const currentStage = process.env.TIF_STAGE as string
const scwProjectId = process.env.SCW_PROJECT_ID as string
const scwAPiToken = process.env.SCW_API_TOKEN as string

const serverlessConfiguration: ScalewayServerlessConfiguration = {
  service: `backend-hasura-handlers-${currentStage}`,
  configValidationMode: 'off',
  useDotenv: false,
  frameworkVersion: '^3.30.1',
  provider: {
    name: 'scaleway',
    runtime: 'node18',
    swcProject: scwProjectId,
    swcRegion: 'fr-par',
    swcToken: scwAPiToken,
    env: {
      TIF_STAGE: '${env:TIF_STAGE}',
      BUCKET_NAME: '${env:BUCKET_NAME}',
      S3_REGION: '${env:S3_REGION, "fr-par"}'
    },
    secret: {
      ACCESS_KEY_ID: '${env:SCW_ACCESS_KEY}',
      SECRET_KEY: '${env:SCW_SECRET_KEY}'
    }
  },
  plugins: ['serverless-esbuild', 'serverless-scaleway-functions'],
  package: {
    individually: true,
    patterns: ['!.gitignore', '!.git/**']
  },
  custom: {
    esbuild: {
      bundle: true,
      minify: false,
      sourcemap: true,
      target: 'node16',
      define: { 'require.resolve': undefined },
      platform: 'node',
      concurrency: 10
    }
  },
  functions: {
    'hello-world': {
      handler: 'src/hello-world/handler.hello-world'
    }
  }
}

console.log(serverlessConfiguration)
export default serverlessConfiguration

But when i try to deploy i run into an error

Error: Invalid service configuration: "provider.name" property is missing  ELIFECYCLE  Command failed with exit code 1.    Does anyone have an idea?

thomas-tacquet commented 1 year ago

Hello 👋

Serverless Framework supports .yaml, .js, .json, .ts but it seems to do not (fully) reconize Scaleway plugin when we use something other than .yaml.

We'll investigate this and link a PR once done, thank you for your report 👌

sanderkooger commented 1 year ago

Hey @thomas-tacquet, As we are discussing on Slack. Would it be a possibility to add typings for the config, handlers etc. to the plugin as well? This would really help to make TS a first class citizen on scale way serverless.

sanderkooger commented 1 year ago

I have been looking into this. Serverless.ts is supported with a caveat. The Scaleway credentials are not being picked up, but they work when env vars are being used.