@nfiny-core/parameter-store
Version:
Exposes AWS Parameter Store GET and PUT functionality
32 lines (27 loc) • 793 B
text/typescript
import AWS from "aws-sdk";
export class AWSParameterStore {
private ssm: AWS.SSM;
constructor() {
this.ssm = new AWS.SSM({ region: "ap-southeast-2" });
}
public async getParameterStoreValue(
path: string,
withDecryption: boolean = false
) {
const resp = await this.ssm
.getParameter({ Name: path, WithDecryption: withDecryption })
.promise();
return resp.Parameter?.Value;
}
public async updateParameterStoreValue(
path: string,
value: string,
type?: string
) {
let isCreating = {};
if (type) isCreating = { Type: type };
const params = { Name: path, Value: value, Overwrite: true, ...isCreating };
const resp = await this.ssm.putParameter(params).promise();
return resp;
}
}