{"id":18699805,"url":"https://github.com/albertomr86/nestjs-param-store","last_synced_at":"2025-07-22T07:31:30.394Z","repository":{"id":58553460,"uuid":"532436546","full_name":"albertomr86/nestjs-param-store","owner":"albertomr86","description":"Configure your NestJS application with AWS Parameter Store","archived":false,"fork":false,"pushed_at":"2024-08-20T04:13:19.000Z","size":728,"stargazers_count":5,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-16T20:46:18.309Z","etag":null,"topics":["aws","aws-ssm","aws-ssm-parameter-store","configuration","nestjs","nestjs-config","nestjs-library","nestjs-module","parameter-store"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/albertomr86.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-04T04:20:11.000Z","updated_at":"2024-03-20T23:45:46.000Z","dependencies_parsed_at":"2024-11-07T11:51:22.363Z","dependency_job_id":null,"html_url":"https://github.com/albertomr86/nestjs-param-store","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/albertomr86/nestjs-param-store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertomr86%2Fnestjs-param-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertomr86%2Fnestjs-param-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertomr86%2Fnestjs-param-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertomr86%2Fnestjs-param-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/albertomr86","download_url":"https://codeload.github.com/albertomr86/nestjs-param-store/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertomr86%2Fnestjs-param-store/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265954076,"owners_count":23854499,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-ssm","aws-ssm-parameter-store","configuration","nestjs","nestjs-config","nestjs-library","nestjs-module","parameter-store"],"created_at":"2024-11-07T11:34:25.873Z","updated_at":"2025-07-22T07:31:30.330Z","avatar_url":"https://github.com/albertomr86.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestJS Config AWS Parameter Store\n\n[![NPM](https://img.shields.io/npm/v/nestjs-param-store.svg)](https://www.npmjs.com/package/nestjs-param-store)\n![Package License](https://img.shields.io/github/license/albertomr86/nestjs-param-store)\n![Build Status](https://github.com/albertomr86/nestjs-param-store/workflows/ci/badge.svg)\n[![codecov](https://codecov.io/gh/albertomr86/nestjs-param-store/graph/badge.svg?token=WT83BVBOZE)](https://codecov.io/gh/albertomr86/nestjs-param-store)\n\nThis package allows you to configure your NestJS application by loading the configuration from [AWS SSM Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html).\n\n## Installation\n\n```bash\nnpm install nestjs-param-store @aws-sdk/client-ssm\n```\n\n## Configuration\n\n### Static configuration\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { PSConfigModule } from 'nestjs-param-store';\n\n@Module({\n  imports: [\n    PSConfigModule.register({\n      ssmParamStorePath: '/production/services/my-service',\n      ssmDecryptParams: true,\n      ssmRecursive: false,\n      ssmClientOptions: {\n        region: 'us-east-1',\n      },\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nBy calling `PSConfigModule.register`, you configure the module to load all the parameters under the path `ssmParamStorePath`.\n\n### Async configuration\n\nThe following example shows how to retrieve the configuration before registering the module.\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { ConfigModule, ConfigService } from '@nestjs/config';\nimport { PSConfigModule } from 'nestjs-param-store';\n\n@Module({\n  imports: [\n    PSConfigModule.registerAsync({\n      imports: [ConfigModule],\n      useFactory: async (config: ConfigService\u003cEnvironmentVariables\u003e) =\u003e ({\n        ssmParamStorePath: config.get\u003cstring\u003e('APP_CONFIG_PATH'),\n        ssmDecryptParams: true,\n        ssmRecursive: false,\n        ssmClientOptions: {\n          region: config.get\u003cstring\u003e('AWS_REGION'),\n        },\n      }),\n      inject: [ConfigService],\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n## Options\n\n| Option            \t| Required \t| Default     \t| Description                                                       \t|\n|-------------------\t|----------\t|-------------\t|-------------------------------------------------------------------\t|\n| ssmParamStorePath \t| Yes      \t|             \t| The hierarchy for the parameter                                   \t|\n| ssmDecryptParams  \t| No       \t| `false`     \t| Retrieve all parameters in a hierarchy with their value decrypted \t|\n| ssmRecursive      \t| No       \t| `false`     \t| Retrieve all parameters within a hierarchy                        \t|\n| ssmClientOptions  \t| No       \t| `undefined` \t| Options to pass to the underlying SSM client                      \t|\n\n## Services\n\nThis module exposes the following services.\n\n### ConfigService\n\nThe `PSConfigService` service allows you to access the configuration loaded from Parameter Store. Use its own class name as the injection token.\n\nLet's assume the following parameters were previously registered:\n\n- `/production/services/my-service/pagination-limit`: '25'\n- `/production/services/my-service/post-table`: 'ProductionPostTable'\n\nConfigure the module with `ssmParamStorePath` pointing to `/production/services/my-service` to access all the parameters register for the service in production.\n\nThen, access the configuration as follows:\n\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport { PSConfigService } from 'nestjs-param-store';\nimport { DynamoDBClient, QueryCommand, GetItemCommand } from '@aws-sdk/client-dynamodb';\n\n@Injectable()\nexport class PostRepository {\n  // Some common initialization.\n  public constructor(\n    private readonly dynamodbClient: DynamoDBClient,\n    private readonly psConfigService: PSConfigService,\n  ) {}\n\n  public getPostsByUser(userId: string) {\n    // Here: Note how to retrieve the configuration.\n    const table = await this.psConfigService.get\u003cstring\u003e('post-table');\n    const limit = await this.psConfigService.get\u003cnumber\u003e('pagination-limit');\n\n    const queryCommand = new QueryCommand({\n      TableName: table, // \u003c- use\n      KeyConditionExpression: 'PK = :pk',\n      ExpressionAttributeValues: {\n        ':pk': { S: `USER#${userId}` },\n      },\n      Limit: limit,  // \u003c- use\n    });\n\n    const { Items = [] } = await this.dynamodbClient.send(queryCommand);\n    // .... snip ....\n  }\n}\n```\n\nThe `PSConfigService` service exposes the following methods:\n\n- `get(name, defaultValue)`: To retrieve a string configuration.\n- `getBool(name, defaultValue)`: To retrieve a boolean configuration. The following values as considered truly: `true`, `True`, `1`, `y`, `yes`, and `Yes`.\n- `getNumber(name, defaultValue)`: To retrieve a numeric configuration.\n\n### How does the PSConfigService service resolve the configurations?\n\nWhen calling `get`, `getBool`, or `getNumber`, the service will look up a parameter whose name ends with the name specified. This means that the match is partial.\n\nGiven the following parameter:\n\n- `/production/services/my-service/pagination-limit`: '25'\n\nIt can be retrieved using one of these alternatives:\n\n- `get('pagination-limit')`\n- `get('my-service/pagination-limit')`\n- `get('services/my-service/pagination-limit')`\n- `get('production/services/my-service/pagination-limit')`\n\n### Raw Parameters\n\nYou can access the raw parameters loaded from the Parameter Store.\n\n```typescript\nimport { Inject, Injectable } from '@nestjs/common';\nimport { PS_CONFIG_PARAMETERS, PSConfigParameters } from 'nestjs-param-store';\n\n@Injectable()\nexport class SophisticatedService {\n  public constructor(\n    @Inject(PS_CONFIG_PARAMETERS) parameters: PSConfigParameters,\n  ) {\n    console.log(parameters);\n  }\n}\n```\n\nExample of output:\n\n```json\n[\n  {\n      \"Name\": \"/production/services/my-service/pagination-limit\",\n      \"Type\": \"String\",\n      \"Value\": \"25\",\n      \"Version\": 1,\n      \"LastModifiedDate\": \"2022-09-03T02:55:00.389000-04:00\",\n      \"ARN\": \"arn:aws:ssm:us-east-1:000000000000:parameter/production/services/my-service/pagination-limit\",\n      \"DataType\": \"text\"\n  },\n  {\n      \"Name\": \"/production/services/my-service/post-table\",\n      \"Type\": \"String\",\n      \"Value\": \"ProductionPostTable\",\n      \"Version\": 1,\n      \"LastModifiedDate\": \"2022-09-03T03:15:15.032000-04:00\",\n      \"ARN\": \"arn:aws:ssm:us-east-1:000000000000:parameter/production/services/my-service/post-table\",\n      \"DataType\": \"text\"\n  }\n]\n```\n\n## Troubleshooting\n\n### Empty list of parameters returned\n\nThis happens when `recursive` is `false` and the specified path does not resolve the final level in the hierarchy.\n\n[Reference: GetParametersByPath](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParametersByPath.html#API_GetParametersByPath_RequestSyntax)\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { PSConfigModule } from 'nestjs-param-store';\n\n@Module({\n  imports: [\n    PSConfigModule.register({\n      ssmParamStorePath: '/production',\n      ssmRecursive: true,   // \u003c-- specify recursively\n    }),\n  ],\n})\nexport class AppModule {}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertomr86%2Fnestjs-param-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbertomr86%2Fnestjs-param-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertomr86%2Fnestjs-param-store/lists"}