Skip to content

Commit 0a0a4d6

Browse files
authored
Add support to decrypt params (#3)
1 parent 856d6f2 commit 0a0a4d6

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This package allows you to configure your NestJS application by loading the conf
77
```bash
88
npm install nestjs-param-store @aws-sdk/client-ssm
99
```
10+
1011
## Configuration
1112

1213
### Static configuration
@@ -19,6 +20,7 @@ import { PSConfigModule } from 'nestjs-param-store';
1920
imports: [
2021
PSConfigModule.register({
2122
ssmParamStorePath: '/production/services/my-service',
23+
ssmDecryptParams: true,
2224
ssmClientOptions: {
2325
region: 'us-east-1',
2426
},
@@ -45,6 +47,7 @@ import { PSConfigModule } from 'nestjs-param-store';
4547
imports: [ConfigModule],
4648
useFactory: async (config: ConfigService<EnvironmentVariables>) => ({
4749
ssmParamStorePath: config.get<string>('APP_CONFIG_PATH'),
50+
ssmDecryptParams: true,
4851
ssmClientOptions: {
4952
region: config.get<string>('AWS_REGION'),
5053
},

lib/interfaces/config-options.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ import { SSMClientConfig } from '@aws-sdk/client-ssm';
22

33
export interface PSConfigOptions {
44
ssmParamStorePath: string;
5+
ssmDecryptParams?: boolean;
56
ssmClientOptions?: SSMClientConfig;
67
}

lib/providers/config-parameters.provider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ export const configParametersProvider: FactoryProvider<PSConfigParameters> = {
99
configOptions: PSConfigOptions,
1010
psService: ParameterStoreService,
1111
): Promise<PSConfigParameters> => {
12-
return psService.getParametersByPath(configOptions.ssmParamStorePath);
12+
return psService.getParametersByPath(
13+
configOptions.ssmParamStorePath,
14+
configOptions.ssmDecryptParams ?? false,
15+
);
1316
},
1417
inject: [PS_CONFIG_OPTIONS, ParameterStoreService],
1518
};

lib/services/parameter-store.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ export class ParameterStoreService {
1212
@Inject(SSM_PS_CLIENT) private readonly client: SSMClient,
1313
) {}
1414

15-
public async getParametersByPath(path: string): Promise<Parameter[]> {
15+
public async getParametersByPath(
16+
path: string,
17+
decrypt = false,
18+
): Promise<Parameter[]> {
1619
const getParameters = new GetParametersByPathCommand({
1720
Path: path,
21+
WithDecryption: decrypt,
1822
});
1923

2024
const { Parameters = [] } = await this.client.send(getParameters);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nestjs-param-store",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Configure your NestJS application with AWS Parameter Store",
55
"author": "Alberto Menendez Romero <albertomr86@gmail.com>",
66
"keywords": [

0 commit comments

Comments
 (0)