forked from dwardu89/aws-ssm-parameter-store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (39 loc) · 1.38 KB
/
index.js
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
37
38
39
40
41
const core = require("@actions/core");
const { SSM } = require("aws-sdk");
async function run() {
try {
var ssm_path = core.getInput("ssm-path", { required: true });
core.info(`Storing Variable in path [${ssm_path}]`);
// Load the AWS Region to use in SSM
core.debug(`Setting aws-region [${core.getInput("aws-region")}]`);
const ssm = new SSM({
apiVersion: "2014-11-06",
region: core.getInput("aws-region"),
});
var params = {
Name: core.getInput("ssm-path", { required: true }),
Value: core.getInput("ssm-value", { required: true }),
Type: core.getInput("ssm-value-type", { required: true }),
Overwrite: core.getBooleanInput("ssm-value-overwrite", {
required: true,
}),
Description: core.getInput("ssm-value-description"),
};
core.debug(
`Prepared parameters for SSM parameter update. ${JSON.stringify(params)}`
);
const keyId = core.getInput("ssm-kms-key-id");
if (params["Type"] === "SecureString" && keyId !== "") {
core.debug(`Setting the KeyId to ${keyId}`);
params["KeyId"] = keyId;
}
var result = await ssm.putParameter(params).promise();
core.debug(
`Parameter details Version [${result.Version}] Tier [${result.Tier}]`
);
core.info(`Successfully Stored parameter in path [${ssm_path}]`);
} catch (error) {
core.setFailed(error.message);
}
}
run();