typescript
typescript copied to clipboard
Support for SSM (AWS's system manager)
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.
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.
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
Hi everyone. There is any example to use SSM in serverless.ts? Thanks!
Hi Frédéric, Thanks for getting back on this issue. Below is the serverless.ts and
ssm
call is in theenvironment
fieldimport 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?
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.
I find it ridiculous that serverless.ts
is being promoted as an official way for typescript app, but there is no documentation whatsoever.
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.
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}",
},