Skip to content
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

serverless.ts not supported? #155

Open
sanderkooger opened this issue Apr 16, 2023 · 3 comments
Open

serverless.ts not supported? #155

sanderkooger opened this issue Apr 16, 2023 · 3 comments

Comments

@sanderkooger
Copy link

sanderkooger commented Apr 16, 2023

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants