-
Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy pathindex.js
111 lines (106 loc) · 3.7 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import * as Scenarios from "@aws-doc-sdk-examples/lib/scenario/index.js";
import {
exitOnFalse,
loadState,
saveState,
} from "@aws-doc-sdk-examples/lib/scenario/steps-common.js";
import { welcome, welcomeContinue } from "./welcome.steps.js";
import {
confirmCreateBuckets,
confirmPopulateBuckets,
confirmSetLegalHoldFileEnabled,
confirmSetLegalHoldFileRetention,
confirmSetRetentionPeriodFileEnabled,
confirmSetRetentionPeriodFileRetention,
confirmUpdateLockPolicy,
confirmUpdateRetention,
createBuckets,
createBucketsAction,
getBucketPrefix,
populateBuckets,
populateBucketsAction,
setLegalHoldFileEnabledAction,
setLegalHoldFileRetentionAction,
setRetentionPeriodFileEnabledAction,
setRetentionPeriodFileRetentionAction,
updateLockPolicy,
updateLockPolicyAction,
updateRetention,
updateRetentionAction,
} from "./setup.steps.js";
/**
* @param {Scenarios} scenarios
* @param {Record<string, any>} initialState
*/
export const getWorkflowStages = (scenarios, initialState = {}) => {
const client = new S3Client({});
return {
deploy: new scenarios.Scenario(
"S3 Object Locking - Deploy",
[
welcome(scenarios),
welcomeContinue(scenarios),
exitOnFalse(scenarios, "welcomeContinue"),
getBucketPrefix(scenarios),
createBuckets(scenarios),
confirmCreateBuckets(scenarios),
exitOnFalse(scenarios, "confirmCreateBuckets"),
createBucketsAction(scenarios, client),
updateRetention(scenarios),
confirmUpdateRetention(scenarios),
exitOnFalse(scenarios, "confirmUpdateRetention"),
updateRetentionAction(scenarios, client),
populateBuckets(scenarios),
confirmPopulateBuckets(scenarios),
exitOnFalse(scenarios, "confirmPopulateBuckets"),
populateBucketsAction(scenarios, client),
updateLockPolicy(scenarios),
confirmUpdateLockPolicy(scenarios),
exitOnFalse(scenarios, "confirmUpdateLockPolicy"),
updateLockPolicyAction(scenarios, client),
confirmSetLegalHoldFileEnabled(scenarios),
setLegalHoldFileEnabledAction(scenarios, client),
confirmSetRetentionPeriodFileEnabled(scenarios),
setRetentionPeriodFileEnabledAction(scenarios, client),
confirmSetLegalHoldFileRetention(scenarios),
setLegalHoldFileRetentionAction(scenarios, client),
confirmSetRetentionPeriodFileRetention(scenarios),
setRetentionPeriodFileRetentionAction(scenarios, client),
saveState,
],
initialState,
),
demo: new scenarios.Scenario(
"S3 Object Locking - Demo",
[loadState, replAction(scenarios, client)],
initialState,
),
clean: new scenarios.Scenario(
"S3 Object Locking - Destroy",
[
loadState,
confirmCleanup(scenarios),
exitOnFalse(scenarios, "confirmCleanup"),
cleanupAction(scenarios, client),
],
initialState,
),
};
};
// Call function if run directly
import { fileURLToPath } from "node:url";
import { S3Client } from "@aws-sdk/client-s3";
import { cleanupAction, confirmCleanup } from "./clean.steps.js";
import { replAction } from "./repl.steps.js";
if (process.argv[1] === fileURLToPath(import.meta.url)) {
const objectLockingScenarios = getWorkflowStages(Scenarios);
Scenarios.parseScenarioArgs(objectLockingScenarios, {
name: "Amazon S3 object locking workflow",
description:
"Work with Amazon Simple Storage Service (Amazon S3) object locking features.",
synopsis:
"node index.js --scenario <deploy | demo | clean> [-h|--help] [-y|--yes] [-v|--verbose]",
});
}