nomoss 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +5 -15
- package/ROADMAP.md +2 -0
- package/docs/README.md +1 -1
- package/docs/application/aws-resource-coverage.md +26 -0
- package/docs/application/aws-resource-lifecycle-management.md +13 -23
- package/docs/application/cli-workflow.md +1 -1
- package/docs/application/engine-design.md +2 -2
- package/docs/application/generation-architecture.md +10 -45
- package/docs/application/resource-command-policy-stage.md +2 -2
- package/docs/application/resource-graph.md +1 -1
- package/docs/application/resource-lifecycle-tracker.md +1 -9
- package/docs/application/resource-mapping.md +4 -9
- package/docs/application/resource-operations.md +4 -2
- package/docs/application/tracing.md +2 -6
- package/docs/development/code-documentation.md +2 -0
- package/docs/development/effect-native-development.md +44 -0
- package/docs/development/linting.md +1 -1
- package/docs/development/review-code.md +22 -6
- package/docs/development/review-remediation-spec.md +28 -37
- package/docs/development/spec-writing.md +1 -1
- package/docs/development/testing.md +23 -9
- package/docs/operations/observability-sop.md +11 -17
- package/docs/operations/releasing.md +3 -1
- package/examples/README.md +3 -26
- package/examples/commands.ts +2 -36
- package/examples/queue/application.ts +8 -2
- package/examples/state-machine/application.ts +3 -1
- package/package.json +40 -46
- package/providers/aws/README.md +21 -0
- package/providers/aws/awsEnvironment.ts +114 -0
- package/providers/aws/generated/managementRegistry.ts +136 -0
- package/{src/providers/aws/resources/generated/native/apigatewayv2/api/index.ts → providers/aws/generated/resources/apigatewayv2/api.ts} +13 -50
- package/{src/providers/aws/resources/generated/native/apigatewayv2/integration/index.ts → providers/aws/generated/resources/apigatewayv2/integration.ts} +13 -37
- package/{src/providers/aws/resources/generated/native/apigatewayv2/route/index.ts → providers/aws/generated/resources/apigatewayv2/route.ts} +23 -40
- package/{src/providers/aws/resources/generated/native/apigatewayv2/stage/index.ts → providers/aws/generated/resources/apigatewayv2/stage.ts} +13 -38
- package/providers/aws/generated/resources/iam/accesskey.ts +184 -0
- package/{src/providers/aws/resources/generated/native/iam/group/index.ts → providers/aws/generated/resources/iam/group.ts} +13 -38
- package/{src/providers/aws/resources/generated/native/iam/grouppolicy/index.ts → providers/aws/generated/resources/iam/grouppolicy.ts} +29 -59
- package/{src/providers/aws/resources/generated/native/iam/instanceprofile/index.ts → providers/aws/generated/resources/iam/instanceprofile.ts} +13 -41
- package/{src/providers/aws/resources/generated/native/iam/managedpolicy/index.ts → providers/aws/generated/resources/iam/managedpolicy.ts} +13 -95
- package/providers/aws/generated/resources/iam/oidcprovider.ts +314 -0
- package/{src/providers/aws/resources/generated/native/iam/policy/index.ts → providers/aws/generated/resources/iam/policy.ts} +13 -28
- package/{src/providers/aws/resources/generated/native/iam/role/index.ts → providers/aws/generated/resources/iam/role.ts} +13 -47
- package/{src/providers/aws/resources/generated/native/iam/rolepolicy/index.ts → providers/aws/generated/resources/iam/rolepolicy.ts} +29 -59
- package/providers/aws/generated/resources/iam/samlprovider.ts +463 -0
- package/providers/aws/generated/resources/iam/servercertificate.ts +465 -0
- package/providers/aws/generated/resources/iam/servicelinkedrole.ts +187 -0
- package/{src/providers/aws/resources/generated/native/iam/user/index.ts → providers/aws/generated/resources/iam/user.ts} +13 -38
- package/{src/providers/aws/resources/generated/native/iam/userpolicy/index.ts → providers/aws/generated/resources/iam/userpolicy.ts} +29 -59
- package/{src/providers/aws/resources/generated/native/iam/usertogroupaddition/index.ts → providers/aws/generated/resources/iam/usertogroupaddition.ts} +13 -27
- package/providers/aws/generated/resources/iam/virtualmfadevice.ts +298 -0
- package/{src/providers/aws/resources/generated/native/kms/key/index.ts → providers/aws/generated/resources/kms/key.ts} +13 -41
- package/{src/providers/aws/resources/generated/native/lambda/function/index.ts → providers/aws/generated/resources/lambda/function.ts} +13 -63
- package/{src/providers/aws/resources/generated/native/lambda/permission/index.ts → providers/aws/generated/resources/lambda/permission.ts} +13 -55
- package/{src/providers/aws/resources/generated/native/s3/bucket/index.ts → providers/aws/generated/resources/s3/bucket.ts} +14 -104
- package/{src/providers/aws/resources/generated/native/sns/topic/index.ts → providers/aws/generated/resources/sns/topic.ts} +14 -29
- package/{src/providers/aws/resources/generated/native/sqs/queue/index.ts → providers/aws/generated/resources/sqs/queue.ts} +14 -38
- package/{src/providers/aws/resources/generated/native/stepfunctions/statemachine/index.ts → providers/aws/generated/resources/stepfunctions/statemachine.ts} +15 -58
- package/providers/aws/management/mappings/iam/group.ts +63 -0
- package/providers/aws/management/mappings/iam/iamIdentity.ts +41 -0
- package/providers/aws/management/mappings/iam/iamLifecycleSettings.ts +8 -0
- package/providers/aws/management/mappings/iam/inlinePolicies.ts +159 -0
- package/providers/aws/management/mappings/iam/instanceProfile.ts +77 -0
- package/providers/aws/management/mappings/iam/oidcProvider.ts +94 -0
- package/providers/aws/management/mappings/iam/role.ts +74 -0
- package/providers/aws/management/mappings/iam/samlProvider.ts +98 -0
- package/providers/aws/management/mappings/iam/serverCertificate.ts +72 -0
- package/providers/aws/management/mappings/iam/user.ts +61 -0
- package/providers/aws/management/mappings/iam/userToGroupAddition.ts +75 -0
- package/providers/aws/management/operations/iam/accessKey.ts +206 -0
- package/providers/aws/management/operations/iam/managedPolicy.ts +491 -0
- package/providers/aws/management/operations/iam/policy.ts +476 -0
- package/providers/aws/management/operations/iam/serviceLinkedRole.ts +172 -0
- package/providers/aws/management/operations/iam/virtualMfaDevice.ts +253 -0
- package/providers/aws/management/resourceAssociationConfiguration.ts +112 -0
- package/providers/aws/management/resourceAssociationRegistration.ts +349 -0
- package/providers/aws/management/resourceAssociations.ts +168 -0
- package/{src/providers → providers}/aws/management/resourceConfiguration.ts +24 -26
- package/providers/aws/management/resourceLifecycleRegistration.ts +540 -0
- package/providers/aws/management/resourceManagementModule.ts +31 -0
- package/providers/aws/management/resourceManagementRegistry.ts +62 -0
- package/providers/aws/management/resourceMapping.ts +84 -0
- package/providers/aws/management/resourceOperation.ts +134 -0
- package/providers/aws/management/resourceTagOperations.ts +108 -0
- package/providers/aws/management/resourceTiming.ts +4 -0
- package/providers/aws/runtime.ts +52 -0
- package/src/core/resource/resourceCommandPolicy.ts +20 -0
- package/src/core/resource/resourceLifecycle.ts +644 -0
- package/src/core/resource/resourceStabilization.ts +120 -0
- package/src/core/resource/resourceVersions.ts +102 -0
- package/src/core/stack/planner.ts +9 -0
- package/src/core/stack/resourceStackLifecycle.ts +36 -3
- package/src/core/state/resourceState.ts +6 -4
- package/src/core/state/stateStore.ts +57 -10
- package/src/providers/file/resourcePolicy.ts +13 -12
- package/src/providers/providerRuntimeLayer.ts +5 -2
- package/src/providers/resourceCommandPolicyLayer.ts +117 -37
- package/src/providers/stripe/management/resourcePolicy.ts +22 -11
- package/examples/http-echo/application.ts +0 -87
- package/src/providers/aws/client/awsClient.ts +0 -418
- package/src/providers/aws/client/awsClientConfig.ts +0 -133
- package/src/providers/aws/client/awsClientModel.ts +0 -119
- package/src/providers/aws/client/awsHttpOperation.ts +0 -153
- package/src/providers/aws/client/awsQueryOperation.ts +0 -149
- package/src/providers/aws/client/awsRequestSigner.ts +0 -115
- package/src/providers/aws/client/awsResponseDecoder.ts +0 -135
- package/src/providers/aws/client/awsRetryPolicy.ts +0 -62
- package/src/providers/aws/client/generated/apiGatewayV2.ts +0 -3025
- package/src/providers/aws/client/generated/cloudControl.ts +0 -5746
- package/src/providers/aws/client/generated/iam.ts +0 -10892
- package/src/providers/aws/client/generated/lambda.ts +0 -5403
- package/src/providers/aws/client/generated/sqs.ts +0 -3769
- package/src/providers/aws/client/generated/stepFunctions.ts +0 -1726
- package/src/providers/aws/client/openapi/cloudControl/CancelResourceRequest.json +0 -579
- package/src/providers/aws/client/openapi/cloudControl/CreateResource.json +0 -1019
- package/src/providers/aws/client/openapi/cloudControl/DeleteResource.json +0 -1018
- package/src/providers/aws/client/openapi/cloudControl/GetResource.json +0 -883
- package/src/providers/aws/client/openapi/cloudControl/GetResourceRequestStatus.json +0 -655
- package/src/providers/aws/client/openapi/cloudControl/ListResourceRequests.json +0 -566
- package/src/providers/aws/client/openapi/cloudControl/ListResources.json +0 -913
- package/src/providers/aws/client/openapi/cloudControl/UpdateResource.json +0 -1027
- package/src/providers/aws/cloudControl/client.ts +0 -69
- package/src/providers/aws/cloudControl/requestTracker.ts +0 -138
- package/src/providers/aws/cloudControl/resourceCommandPolicyLayer.ts +0 -63
- package/src/providers/aws/cloudControl/resourceLifecycle.ts +0 -479
- package/src/providers/aws/cloudControl/resources/generated/certificatemanager/certificate/index.ts +0 -179
- package/src/providers/aws/cloudControl/resources/generated/kms/key/index.ts +0 -362
- package/src/providers/aws/cloudControl/resources/generated/s3/bucket/index.ts +0 -2364
- package/src/providers/aws/cloudControl/resources/generated/sns/topic/index.ts +0 -326
- package/src/providers/aws/cloudControl/resources/generated/sqs/queue/index.ts +0 -307
- package/src/providers/aws/cloudControl/resources/generated/sqs/queueinlinepolicy/index.ts +0 -108
- package/src/providers/aws/cloudControl/runtime.ts +0 -127
- package/src/providers/aws/management/resourceMapping.ts +0 -343
- package/src/providers/aws/management/resourceOperation.ts +0 -57
- package/src/providers/aws/management/resourcePolicy.ts +0 -549
- package/src/providers/aws/management/resourceRegistration.ts +0 -294
- package/src/providers/aws/resources/apiGatewayV2/httpApi.ts +0 -327
- package/src/providers/aws/resources/generated/native/resourceCommands.ts +0 -152
- package/src/providers/aws/resources/iam/grant.ts +0 -150
- package/src/providers/aws/resources/iam/grantCommands.ts +0 -283
- package/src/providers/aws/resources/iam/policyDocument.ts +0 -30
- package/src/providers/aws/resources/iam/policyStatement.ts +0 -59
- package/src/providers/aws/resources/iam/role.ts +0 -426
- package/src/providers/aws/resources/iam/roleDeclaration.ts +0 -105
- package/src/providers/aws/resources/lambda/function.ts +0 -403
- package/src/providers/aws/resources/lambda/functionDeclaration.ts +0 -234
- package/src/providers/aws/resources/lambda/permission.ts +0 -363
- package/src/providers/aws/resources/stepFunctions/stateMachine.ts +0 -95
- package/src/providers/aws/runtime.ts +0 -70
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Context, Effect, HashSet, Option, Stream, Tuple } from "effect";
|
|
2
|
-
import { AwsRequestError } from "../client/awsClientModel.js";
|
|
3
|
-
import {
|
|
4
|
-
type ListResourcesInput,
|
|
5
|
-
makeCloudControlClient,
|
|
6
|
-
type ResourceDescription,
|
|
7
|
-
} from "../client/generated/cloudControl.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* AwsCloudControlClient exposes generated Cloud Control operations with
|
|
11
|
-
* pagination for resource discovery. Discovery shares operation validation
|
|
12
|
-
* and execution with direct requests through the internal AWS client.
|
|
13
|
-
*/
|
|
14
|
-
export class AwsCloudControlClient extends Context.Service<AwsCloudControlClient>()(
|
|
15
|
-
"nomoss/providers/aws/cloudControl/client/AwsCloudControlClient",
|
|
16
|
-
{
|
|
17
|
-
make: Effect.gen(function* () {
|
|
18
|
-
const generated = yield* makeCloudControlClient;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The listResourceDescriptions service method supplies discovery pages
|
|
22
|
-
* until AWS omits the continuation token. A repeated token fails discovery
|
|
23
|
-
* so a malformed response cannot cause an endless pagination loop.
|
|
24
|
-
*/
|
|
25
|
-
const listResourceDescriptions = (input: ListResourcesInput) => {
|
|
26
|
-
const initial = {
|
|
27
|
-
request: input,
|
|
28
|
-
tokens: HashSet.fromIterable(
|
|
29
|
-
Option.toArray(Option.fromUndefinedOr(input.NextToken)),
|
|
30
|
-
),
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const descriptions = Stream.paginate(initial, (state) =>
|
|
34
|
-
generated.listResources(state.request).pipe(
|
|
35
|
-
Effect.filterOrFail(
|
|
36
|
-
(response) =>
|
|
37
|
-
Option.fromUndefinedOr(response.NextToken).pipe(
|
|
38
|
-
Option.map((token) => !HashSet.has(state.tokens, token)),
|
|
39
|
-
Option.getOrElse(() => true),
|
|
40
|
-
),
|
|
41
|
-
() =>
|
|
42
|
-
new AwsRequestError({
|
|
43
|
-
message: "Cloud Control returned a repeated pagination token",
|
|
44
|
-
}),
|
|
45
|
-
),
|
|
46
|
-
Effect.map((response) => {
|
|
47
|
-
const resources: ReadonlyArray<ResourceDescription> =
|
|
48
|
-
response.ResourceDescriptions ?? [];
|
|
49
|
-
const next = Option.fromUndefinedOr(response.NextToken).pipe(
|
|
50
|
-
Option.map((NextToken) => ({
|
|
51
|
-
request: { ...state.request, NextToken },
|
|
52
|
-
tokens: HashSet.add(state.tokens, NextToken),
|
|
53
|
-
})),
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const page = Tuple.make(resources, next);
|
|
57
|
-
|
|
58
|
-
return page;
|
|
59
|
-
}),
|
|
60
|
-
),
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
return descriptions;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
return { ...generated, listResourceDescriptions };
|
|
67
|
-
}),
|
|
68
|
-
},
|
|
69
|
-
) {}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Context,
|
|
3
|
-
Data,
|
|
4
|
-
Duration,
|
|
5
|
-
Effect,
|
|
6
|
-
Match,
|
|
7
|
-
Option,
|
|
8
|
-
Schedule,
|
|
9
|
-
} from "effect";
|
|
10
|
-
import type { ProgressEvent } from "../client/generated/cloudControl.js";
|
|
11
|
-
import { AwsCloudControlClient } from "./client.js";
|
|
12
|
-
|
|
13
|
-
export class AwsCloudControlRequestFailed extends Data.TaggedError(
|
|
14
|
-
"AwsCloudControlRequestFailed",
|
|
15
|
-
)<{ readonly typeName: string; readonly cause: unknown }> {
|
|
16
|
-
override get message() {
|
|
17
|
-
return Match.value(this.cause).pipe(
|
|
18
|
-
Match.when(
|
|
19
|
-
(cause: unknown): cause is Error => cause instanceof Error,
|
|
20
|
-
(cause: Error) => cause.message,
|
|
21
|
-
),
|
|
22
|
-
Match.orElse(
|
|
23
|
-
() => `AWS Cloud Control request failed for ${this.typeName}`,
|
|
24
|
-
),
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export class AwsCloudControlOperationFailed extends Data.TaggedError(
|
|
30
|
-
"AwsCloudControlOperationFailed",
|
|
31
|
-
)<{
|
|
32
|
-
readonly typeName: string;
|
|
33
|
-
readonly errorCode?: ProgressEvent["ErrorCode"];
|
|
34
|
-
readonly message?: string;
|
|
35
|
-
}> {}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* AwsCloudControlRequestTracker waits for AWS to finish an accepted resource
|
|
39
|
-
* mutation. Lifecycle operations wait for the terminal result before they read
|
|
40
|
-
* outputs or allow dependent resources to proceed.
|
|
41
|
-
*/
|
|
42
|
-
export class AwsCloudControlRequestTracker extends Context.Service<AwsCloudControlRequestTracker>()(
|
|
43
|
-
"nomoss/providers/aws/cloudControl/requestTracker/AwsCloudControlRequestTracker",
|
|
44
|
-
{
|
|
45
|
-
make: Effect.gen(function* () {
|
|
46
|
-
const { getResourceRequestStatus } = yield* AwsCloudControlClient;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* awaitResourceRequest returns successful terminal progress or a typed
|
|
50
|
-
* failure for the request token.
|
|
51
|
-
* Status checks use the AWS CLI waiter's five-second interval.
|
|
52
|
-
* Interruption stops local requests and waits; accepted work in AWS
|
|
53
|
-
* requires separate cancellation.
|
|
54
|
-
*/
|
|
55
|
-
const awaitResourceRequest = Effect.fn(
|
|
56
|
-
"AwsCloudControlRequestTracker.awaitResourceRequest",
|
|
57
|
-
)(function* (input: {
|
|
58
|
-
readonly typeName: string;
|
|
59
|
-
readonly requestToken: string;
|
|
60
|
-
}) {
|
|
61
|
-
yield* Effect.annotateCurrentSpan({
|
|
62
|
-
"aws.cloudcontrol.type_name": input.typeName,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const progress: ProgressEvent = yield* getResourceRequestStatus({
|
|
66
|
-
RequestToken: input.requestToken,
|
|
67
|
-
}).pipe(
|
|
68
|
-
Effect.mapError(
|
|
69
|
-
(cause) =>
|
|
70
|
-
new AwsCloudControlRequestFailed({
|
|
71
|
-
typeName: input.typeName,
|
|
72
|
-
cause,
|
|
73
|
-
}),
|
|
74
|
-
),
|
|
75
|
-
Effect.flatMap(({ ProgressEvent }) =>
|
|
76
|
-
Option.fromUndefinedOr(ProgressEvent).pipe(
|
|
77
|
-
Effect.fromOption,
|
|
78
|
-
Effect.mapError(
|
|
79
|
-
() =>
|
|
80
|
-
new AwsCloudControlOperationFailed({
|
|
81
|
-
typeName: input.typeName,
|
|
82
|
-
}),
|
|
83
|
-
),
|
|
84
|
-
),
|
|
85
|
-
),
|
|
86
|
-
Effect.filterOrFail(
|
|
87
|
-
(event) =>
|
|
88
|
-
event.OperationStatus === "SUCCESS" ||
|
|
89
|
-
event.OperationStatus === "PENDING" ||
|
|
90
|
-
event.OperationStatus === "IN_PROGRESS",
|
|
91
|
-
(event) =>
|
|
92
|
-
new AwsCloudControlOperationFailed({
|
|
93
|
-
typeName: input.typeName,
|
|
94
|
-
errorCode: event.ErrorCode,
|
|
95
|
-
message: event.StatusMessage,
|
|
96
|
-
}),
|
|
97
|
-
),
|
|
98
|
-
Effect.flatMap((event) =>
|
|
99
|
-
Effect.gen(function* () {
|
|
100
|
-
yield* Effect.logInfo("Cloud Control request progress").pipe(
|
|
101
|
-
Effect.annotateLogs({
|
|
102
|
-
"aws.cloudcontrol.type_name": input.typeName,
|
|
103
|
-
"aws.cloudcontrol.operation": event.Operation,
|
|
104
|
-
"aws.cloudcontrol.status": event.OperationStatus,
|
|
105
|
-
"aws.cloudcontrol.retry_after": event.RetryAfter,
|
|
106
|
-
}),
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
yield* Effect.logInfo(
|
|
110
|
-
"Waiting to poll Cloud Control request",
|
|
111
|
-
).pipe(
|
|
112
|
-
Effect.annotateLogs({
|
|
113
|
-
"aws.cloudcontrol.type_name": input.typeName,
|
|
114
|
-
"aws.cloudcontrol.status": event.OperationStatus,
|
|
115
|
-
"aws.cloudcontrol.poll_delay_ms": 5000,
|
|
116
|
-
}),
|
|
117
|
-
Effect.when(
|
|
118
|
-
Effect.succeed(event.OperationStatus !== "SUCCESS"),
|
|
119
|
-
),
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
return event;
|
|
123
|
-
}),
|
|
124
|
-
),
|
|
125
|
-
Effect.repeat({
|
|
126
|
-
until: (progressEvent) =>
|
|
127
|
-
progressEvent.OperationStatus === "SUCCESS",
|
|
128
|
-
schedule: Schedule.spaced(Duration.seconds(5)),
|
|
129
|
-
}),
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
return progress;
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
return { awaitResourceRequest };
|
|
136
|
-
}),
|
|
137
|
-
},
|
|
138
|
-
) {}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Effect, Layer, Match } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
type ResourceCommand,
|
|
4
|
-
type ResourceCommandResult,
|
|
5
|
-
ResourceCommandUnsupported,
|
|
6
|
-
} from "../../../core/resource/lifecycle.js";
|
|
7
|
-
import { ResourceCommandExecutionFailed } from "../../../core/resource/resourceCommandPolicy.js";
|
|
8
|
-
import { awsCloudControlCommandPolicyTag } from "../../resourceCommandPolicyLayer.js";
|
|
9
|
-
import { AwsCloudControlResourceLifecycle } from "./resourceLifecycle.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* awsCloudControlResourceCommandMetadataLayer registers Cloud Control resource
|
|
13
|
-
* operations for core command dispatch in the application's runtime. Other
|
|
14
|
-
* configured providers retain separate registrations in the same graph.
|
|
15
|
-
*/
|
|
16
|
-
export const awsCloudControlResourceCommandMetadataLayer = Layer.unwrap(
|
|
17
|
-
Effect.gen(function* () {
|
|
18
|
-
const lifecycle = yield* AwsCloudControlResourceLifecycle;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* execute supports resource reads and Apply decisions for creation, update,
|
|
22
|
-
* and destruction. Other requests, including an Apply Delete decision,
|
|
23
|
-
* return ResourceCommandUnsupported inside ResourceCommandExecutionFailed.
|
|
24
|
-
*/
|
|
25
|
-
const execute = Effect.fn("AwsCloudControlResourceCommandMetadata.execute")(
|
|
26
|
-
function* (command: ResourceCommand) {
|
|
27
|
-
const result: ResourceCommandResult = yield* Effect.mapError(
|
|
28
|
-
Match.value(command).pipe(
|
|
29
|
-
Match.tag("Apply", ({ decision }) =>
|
|
30
|
-
Match.value(decision).pipe(
|
|
31
|
-
Match.tag("Create", ({ node }) =>
|
|
32
|
-
lifecycle.createResource(node),
|
|
33
|
-
),
|
|
34
|
-
Match.tag("Update", ({ node, current }) =>
|
|
35
|
-
lifecycle.updateResource(node, current),
|
|
36
|
-
),
|
|
37
|
-
Match.tag("Destroy", ({ node }) =>
|
|
38
|
-
lifecycle.destroyResource(node),
|
|
39
|
-
),
|
|
40
|
-
Match.orElse(() =>
|
|
41
|
-
Effect.fail(new ResourceCommandUnsupported({ command })),
|
|
42
|
-
),
|
|
43
|
-
),
|
|
44
|
-
),
|
|
45
|
-
Match.tag("Read", ({ node }) => lifecycle.readResource(node)),
|
|
46
|
-
Match.orElse(() =>
|
|
47
|
-
Effect.fail(new ResourceCommandUnsupported({ command })),
|
|
48
|
-
),
|
|
49
|
-
),
|
|
50
|
-
(cause) => new ResourceCommandExecutionFailed({ command, cause }),
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
return result;
|
|
54
|
-
},
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const registration = Layer.succeed(awsCloudControlCommandPolicyTag, {
|
|
58
|
-
execute,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
return registration;
|
|
62
|
-
}),
|
|
63
|
-
);
|