Skip to content

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

Open

Description

@appletreeat56

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.

Activity

  1. fredericbarthelet commented on Jan 23, 2022

    @fredericbarthelet
    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.

  2. appletreeat56 commented on Jan 24, 2022

    @appletreeat56
    Author

    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
    
  3. pascencio commented on May 23, 2022

    @pascencio

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

  4. pascencio commented on Jun 17, 2022

    @pascencio

    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?

  5. gruckion commented on Sep 13, 2022

    @gruckion

    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.

  6. DimmKirr commented on Sep 22, 2022

    @DimmKirr

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

  7. gruckion commented on Oct 7, 2022

    @gruckion

    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.

  8. Physicliar commented on Feb 12, 2023

    @Physicliar

    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}",
        },
    
  9. kristijorgji commented on Aug 8, 2024

    @kristijorgji

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions