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

Support for SSM (AWS's system manager) #59

Open
appletreeat56 opened this issue Jan 23, 2022 · 9 comments
Open

Support for SSM (AWS's system manager) #59

appletreeat56 opened this issue Jan 23, 2022 · 9 comments

Comments

@appletreeat56
Copy link

Hi,
I have been trying to access ssm on serverless.ts file but I keep getting this error -

Serverless Warning --------------------------------------
A valid SSM parameter to satisfy the declaration 'ssm:/oath/to/ssm' could not be found.

It use to work fine on serverless.yml. I have looked at the definition file and I could not see any reference to ssm either, so I am assuming that it is not supported. If so, can you please confirm?

p.s: I can confirm that this ssm entry does exist on AWS and I can access it via AWS CLI.

@fredericbarthelet
Copy link
Contributor

Hi @appletreeat56 and thanks for submitting your issue.
Could you please share your serverless.ts service file content here ?

This repository translates Serverless framework internal validation constraints in Typescript definition. Anything supported by the framework is reflected here.

@appletreeat56
Copy link
Author

appletreeat56 commented Jan 24, 2022

Hi Frédéric, Thanks for getting back on this issue. Below is the serverless.ts and ssm call is in the environment field


import type { AWS } from '@serverless/typescript';

const serverlessConfiguration: AWS = {
  service: 'jsontoxlsx',
  frameworkVersion: '2',
  custom: {
    webpack: {
      webpackConfig: './webpack.config.js',
      includeModules: true
    },
  },
  // Add the serverless-webpack plugin
  plugins: ['serverless-webpack', 'serverless-offline'],
  provider: {
    name: 'aws',
    runtime: 'nodejs14.x',
    apiGateway: {
      minimumCompressionSize: 1024,
    },
    environment: {
      AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
      AWS_BUCKET_NAME: '${ssm:/jsontoxlsx/api/BUCKET_NAME}'
    },
  },
  functions: {
    jsontoxlsx: {
      handler: 'handler.jsontoxlsx',
      events: [
        {
          http: {
            method: 'get',
            path: 'jsontoxlsx',
          }
        }
      ]
    }
  }
}

module.exports = serverlessConfiguration;

I am using this version of serverless in my package.json - "@serverless/typescript": "^2.12.0"

And this is my serveless version installed globally -

Framework Core: 2.14.0
Plugin: 4.1.2
SDK: 2.3.2
Components: 3.4.2

@pascencio
Copy link

Hi everyone. There is any example to use SSM in serverless.ts? Thanks!

@pascencio
Copy link

Hi Frédéric, Thanks for getting back on this issue. Below is the serverless.ts and ssm call is in the environment field


import type { AWS } from '@serverless/typescript';

const serverlessConfiguration: AWS = {
  service: 'jsontoxlsx',
  frameworkVersion: '2',
  custom: {
    webpack: {
      webpackConfig: './webpack.config.js',
      includeModules: true
    },
  },
  // Add the serverless-webpack plugin
  plugins: ['serverless-webpack', 'serverless-offline'],
  provider: {
    name: 'aws',
    runtime: 'nodejs14.x',
    apiGateway: {
      minimumCompressionSize: 1024,
    },
    environment: {
      AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
      AWS_BUCKET_NAME: '${ssm:/jsontoxlsx/api/BUCKET_NAME}'
    },
  },
  functions: {
    jsontoxlsx: {
      handler: 'handler.jsontoxlsx',
      events: [
        {
          http: {
            method: 'get',
            path: 'jsontoxlsx',
          }
        }
      ]
    }
  }
}

module.exports = serverlessConfiguration;

I am using this version of serverless in my package.json - "@serverless/typescript": "^2.12.0"

And this is my serveless version installed globally -

Framework Core: 2.14.0
Plugin: 4.1.2
SDK: 2.3.2
Components: 3.4.2

I have the same problem... There is some work around?

@gruckion
Copy link

It's a shame that this is not documented. Only an example with serverless.yml is given and there is no mention of it doing "magic" in the background to produce IAM roles to allow SSM to be read from AWS.

@AutomationD
Copy link

I find it ridiculous that serverless.ts is being promoted as an official way for typescript app, but there is no documentation whatsoever.

@gruckion
Copy link

gruckion commented Oct 7, 2022

So turns out this works fine, my issue was a spelling mistake.

    environment: {
      AWS_NODEJS_CONNECTION_REUSE_ENABLED: "1",
      // TODO (Stephen): need to correct which stage the secret lives hard coding to live for now ${ssm:/${opt:stage, 'live'}
      APP_DB_INSTANCE_SECRET_ARN:
        "${ssm:/live/secrets/rds/app-db-instance-secret-arn}",
    },

And my secret does exist with that name. Works fine no issues. Please could you show that you actually have the parameter store value setup. Also check the parameter and the region your serverless is deployed to is the same.

@Physicliar
Copy link

Above worked else for me even locally

    environment: {
      AWS_NODEJS_CONNECTION_REUSE_ENABLED: "1",
      // TODO (Stephen): need to correct which stage the secret lives hard coding to live for now ${ssm:/${opt:stage, 'live'}
      APP_DB_INSTANCE_SECRET_ARN:
        "${ssm:/live/secrets/rds/app-db-instance-secret-arn}",
    },

@kristijorgji
Copy link

Default value is not working anymore in last serverless version 4.1.19

        provisionedConcurrency: ${ssm:/${self:provider.stage}/${self:provider.region}/applications/${self:custom.serviceName}/provisioned-concurrency, 0}

Error Failed to resolve variable

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

7 participants