Node Module to Retrieve Multiple Parameters from AWS Parameter Store

I created a node module to retrieve multiple parameters as the parameterName-parameterValue Json object from AWS Parameter Store. It is called aws-ssm-parameters and is available from Npm. The module is namespaced. So, you need to add the namespace @mdhnpm when you install it.

npm i @mdhnpm/aws-ssm-parameters

The main motivation for creating this module is to use it in lambda functions where I add parameter names in environment variables and use aws-sdk to retrieve them. I find this pattern cleaner than just adding real database passwords or API credentials to environment variables. It creates an extra layer of security and rotating credentials do not require re-deployment of lambda functions (or worse editing credentials directly in the lambda console). I just didn’t want to repeat the same logic again and again in all the lambda functions.

The great thing about npm is that the module does not need to be big. It can be namespaced and your private module feels a little more personal although it’s accessible to the public. It also allows you to create a private repo for an organisation. This is a great way to share node modules within the enterprise.

My module is super simple. It is based on aws-sdk. It has a method getParameters() which retrieves all the parameters at once. What I did was creating a thin wrapper to make it usable with one line.

Here is the source code.

The usage is simple. My recommendation is to use ES7 async/await pattern. It makes code nicer.

There are more …

Now the sdk has a method to retrieve a single parameter getParameter().

Then, we can loop through them and use reduce() function to create home-made getParameters function. Isn’t it fun?

You can check the source code along with unit tests here.

Front-End
TypeScript: type aliases to check type equality

This post is to analyse how the type equality check by using type aliases proposed by Matt Pocock in his twitter post. These type aliases allow us to elegantly express type equality checks in unit tests. All we need to do is to pass the output and expected types in …

Front-End
Fixing it.only type error in Jest

If you are getting a type error with it.only in Jest, it could be due to incorrect TypeScript typings or incompatible versions of Jest and TypeScript. To resolve this issue, you can try the following steps: Make sure you have the latest versions of Jest and its TypeScript typings installed …

Front-End
yup conditional validation example

Here’s an example of a Yup validation logic where the first input field is optional but, if filled, it must contain only alphabetic characters, and the second input field is required: import * as Yup from “yup”; const validationSchema = Yup.object().shape({ firstField: Yup.string().matches(/^[A-Za-z]*$/, { message: “First field must contain only …