forked from antimatter-studios/ssm-local
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetParameter.ts
36 lines (30 loc) · 1.03 KB
/
GetParameter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { GetParameterRequest, GetParameterResult } from "aws-sdk/clients/ssm";
import { Services } from "../services";
import { Target } from "./Target";
import { ParameterNotFoundError } from "../errors/ParameterNotFoundError";
export type GetParameterTarget = Target<
GetParameterRequest,
GetParameterResult
>;
export const GetParameter =
({ ssm }: Pick<Services, "ssm">): GetParameterTarget =>
async (ctx, req) => {
ctx.logger.debug({ req });
const result = await ssm.get(ctx, req.Name);
if (!result) {
throw new ParameterNotFoundError();
}
const region = "eu-west-1";
const account_id = "112233445566";
return await Promise.resolve({
Parameter: {
Name: result.Metadata.Name,
Type: result.Metadata.Type,
Value: result.Value,
Version: result.Metadata.Version,
LastModifiedDate: result.Metadata.LastModifiedDate,
ARN: `arn:aws:ssm:${region}:${account_id}:parameter${result.Metadata.Name}`,
DataType: result.Metadata.DataType,
},
});
};