Skip to content

Commit 951d77b

Browse files
committed
feat: implement decryption
Signed-off-by: Giovanni De Giorgio <[email protected]>
1 parent 5578de2 commit 951d77b

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

libs/providers/aws-ssm/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,26 @@ OpenFeature.setProvider(
3030
})
3131
);
3232
```
33+
34+
# AWS SSM Provider Configuration
35+
36+
## AwsSsmProviderConfig
37+
38+
| Property | Type | Description | Default |
39+
|-----------------|--------------------|----------------------------------------------|---------|
40+
| `ssmClientConfig` | `SSMClientConfig` | AWS SSM Client configuration options. | See [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ssm/) |
41+
| `enableDecryption` | `boolean` | Enable decryption for SecureString parameters | false |
42+
| `cacheOpts` | `LRUCacheConfig` | Configuration for the local LRU cache. | See below |
43+
44+
## LRUCacheConfig
45+
46+
| Property | Type | Description | Default |
47+
|-----------|--------|------------------------------------------------|---------|
48+
| `enabled` | `boolean` | Whether caching is enabled. | `true` |
49+
| `ttl` | `number` | Time-to-live (TTL) for cached items (in ms). | `300000` (5 minutes) |
50+
| `size` | `number` | Maximum number of items in the cache. | `1000` |
51+
52+
3353
## Retrieve Feature Flag!
3454

3555
Create a new SSM Param called 'my-feature-flag' in your AWS Account and then retrieve it via OpenFeature Client!

libs/providers/aws-ssm/src/lib/aws-ssm-provider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class AwsSsmProvider implements Provider {
2222
cache: Cache;
2323

2424
constructor(config: AwsSsmProviderConfig) {
25-
this.service = new SSMService(config.ssmClientConfig);
25+
this.service = new SSMService(config.ssmClientConfig, config.enableDecryption);
2626
this.cache = new Cache(config.cacheOpts);
2727
}
2828

libs/providers/aws-ssm/src/lib/cache.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ export class Cache {
88
private enabled: boolean;
99
constructor(opts: LRUCacheConfig) {
1010
this.cache = new LRUCache({
11-
maxSize: opts.size,
11+
maxSize: opts.size ?? 1000,
1212
sizeCalculation: () => 1,
1313
});
14-
this.ttl = opts.ttl;
14+
this.ttl = opts.ttl ?? 300000;
1515
this.enabled = opts.enabled;
1616
}
1717

libs/providers/aws-ssm/src/lib/ssm-service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import {
1818
export class SSMService {
1919
client: SSMClient;
2020
enableDecryption: boolean;
21-
constructor(config: SSMClientConfig, enableDecryption: boolean = false) {
21+
constructor(config: SSMClientConfig, enableDecryption?: boolean) {
2222
this.client = new SSMClient(config);
23-
this.enableDecryption = enableDecryption;
23+
this.enableDecryption = enableDecryption ?? false;
2424
}
2525

2626
async getBooleanValue(name: string): Promise<ResolutionDetails<boolean>> {

libs/providers/aws-ssm/src/lib/types.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { SSMClientConfig } from '@aws-sdk/client-ssm';
33
export type AwsSsmProviderConfig = {
44
ssmClientConfig: SSMClientConfig;
55
cacheOpts: LRUCacheConfig;
6+
enableDecryption?: boolean;
67
};
78

89
export type LRUCacheConfig = {
910
enabled: boolean;
10-
ttl: number;
11-
size: number;
11+
ttl?: number;
12+
size?: number;
1213
};

0 commit comments

Comments
 (0)