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.
Files changed (150) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +5 -15
  3. package/ROADMAP.md +2 -0
  4. package/docs/README.md +1 -1
  5. package/docs/application/aws-resource-coverage.md +26 -0
  6. package/docs/application/aws-resource-lifecycle-management.md +13 -23
  7. package/docs/application/cli-workflow.md +1 -1
  8. package/docs/application/engine-design.md +2 -2
  9. package/docs/application/generation-architecture.md +10 -45
  10. package/docs/application/resource-command-policy-stage.md +2 -2
  11. package/docs/application/resource-graph.md +1 -1
  12. package/docs/application/resource-lifecycle-tracker.md +1 -9
  13. package/docs/application/resource-mapping.md +4 -9
  14. package/docs/application/resource-operations.md +4 -2
  15. package/docs/application/tracing.md +2 -6
  16. package/docs/development/code-documentation.md +2 -0
  17. package/docs/development/effect-native-development.md +44 -0
  18. package/docs/development/linting.md +1 -1
  19. package/docs/development/review-code.md +22 -6
  20. package/docs/development/review-remediation-spec.md +28 -37
  21. package/docs/development/spec-writing.md +1 -1
  22. package/docs/development/testing.md +23 -9
  23. package/docs/operations/observability-sop.md +11 -17
  24. package/docs/operations/releasing.md +3 -1
  25. package/examples/README.md +3 -26
  26. package/examples/commands.ts +2 -36
  27. package/examples/queue/application.ts +8 -2
  28. package/examples/state-machine/application.ts +3 -1
  29. package/package.json +40 -46
  30. package/providers/aws/README.md +21 -0
  31. package/providers/aws/awsEnvironment.ts +114 -0
  32. package/providers/aws/generated/managementRegistry.ts +136 -0
  33. package/{src/providers/aws/resources/generated/native/apigatewayv2/api/index.ts → providers/aws/generated/resources/apigatewayv2/api.ts} +13 -50
  34. package/{src/providers/aws/resources/generated/native/apigatewayv2/integration/index.ts → providers/aws/generated/resources/apigatewayv2/integration.ts} +13 -37
  35. package/{src/providers/aws/resources/generated/native/apigatewayv2/route/index.ts → providers/aws/generated/resources/apigatewayv2/route.ts} +23 -40
  36. package/{src/providers/aws/resources/generated/native/apigatewayv2/stage/index.ts → providers/aws/generated/resources/apigatewayv2/stage.ts} +13 -38
  37. package/providers/aws/generated/resources/iam/accesskey.ts +184 -0
  38. package/{src/providers/aws/resources/generated/native/iam/group/index.ts → providers/aws/generated/resources/iam/group.ts} +13 -38
  39. package/{src/providers/aws/resources/generated/native/iam/grouppolicy/index.ts → providers/aws/generated/resources/iam/grouppolicy.ts} +29 -59
  40. package/{src/providers/aws/resources/generated/native/iam/instanceprofile/index.ts → providers/aws/generated/resources/iam/instanceprofile.ts} +13 -41
  41. package/{src/providers/aws/resources/generated/native/iam/managedpolicy/index.ts → providers/aws/generated/resources/iam/managedpolicy.ts} +13 -95
  42. package/providers/aws/generated/resources/iam/oidcprovider.ts +314 -0
  43. package/{src/providers/aws/resources/generated/native/iam/policy/index.ts → providers/aws/generated/resources/iam/policy.ts} +13 -28
  44. package/{src/providers/aws/resources/generated/native/iam/role/index.ts → providers/aws/generated/resources/iam/role.ts} +13 -47
  45. package/{src/providers/aws/resources/generated/native/iam/rolepolicy/index.ts → providers/aws/generated/resources/iam/rolepolicy.ts} +29 -59
  46. package/providers/aws/generated/resources/iam/samlprovider.ts +463 -0
  47. package/providers/aws/generated/resources/iam/servercertificate.ts +465 -0
  48. package/providers/aws/generated/resources/iam/servicelinkedrole.ts +187 -0
  49. package/{src/providers/aws/resources/generated/native/iam/user/index.ts → providers/aws/generated/resources/iam/user.ts} +13 -38
  50. package/{src/providers/aws/resources/generated/native/iam/userpolicy/index.ts → providers/aws/generated/resources/iam/userpolicy.ts} +29 -59
  51. package/{src/providers/aws/resources/generated/native/iam/usertogroupaddition/index.ts → providers/aws/generated/resources/iam/usertogroupaddition.ts} +13 -27
  52. package/providers/aws/generated/resources/iam/virtualmfadevice.ts +298 -0
  53. package/{src/providers/aws/resources/generated/native/kms/key/index.ts → providers/aws/generated/resources/kms/key.ts} +13 -41
  54. package/{src/providers/aws/resources/generated/native/lambda/function/index.ts → providers/aws/generated/resources/lambda/function.ts} +13 -63
  55. package/{src/providers/aws/resources/generated/native/lambda/permission/index.ts → providers/aws/generated/resources/lambda/permission.ts} +13 -55
  56. package/{src/providers/aws/resources/generated/native/s3/bucket/index.ts → providers/aws/generated/resources/s3/bucket.ts} +14 -104
  57. package/{src/providers/aws/resources/generated/native/sns/topic/index.ts → providers/aws/generated/resources/sns/topic.ts} +14 -29
  58. package/{src/providers/aws/resources/generated/native/sqs/queue/index.ts → providers/aws/generated/resources/sqs/queue.ts} +14 -38
  59. package/{src/providers/aws/resources/generated/native/stepfunctions/statemachine/index.ts → providers/aws/generated/resources/stepfunctions/statemachine.ts} +15 -58
  60. package/providers/aws/management/mappings/iam/group.ts +63 -0
  61. package/providers/aws/management/mappings/iam/iamIdentity.ts +41 -0
  62. package/providers/aws/management/mappings/iam/iamLifecycleSettings.ts +8 -0
  63. package/providers/aws/management/mappings/iam/inlinePolicies.ts +159 -0
  64. package/providers/aws/management/mappings/iam/instanceProfile.ts +77 -0
  65. package/providers/aws/management/mappings/iam/oidcProvider.ts +94 -0
  66. package/providers/aws/management/mappings/iam/role.ts +74 -0
  67. package/providers/aws/management/mappings/iam/samlProvider.ts +98 -0
  68. package/providers/aws/management/mappings/iam/serverCertificate.ts +72 -0
  69. package/providers/aws/management/mappings/iam/user.ts +61 -0
  70. package/providers/aws/management/mappings/iam/userToGroupAddition.ts +75 -0
  71. package/providers/aws/management/operations/iam/accessKey.ts +206 -0
  72. package/providers/aws/management/operations/iam/managedPolicy.ts +491 -0
  73. package/providers/aws/management/operations/iam/policy.ts +476 -0
  74. package/providers/aws/management/operations/iam/serviceLinkedRole.ts +172 -0
  75. package/providers/aws/management/operations/iam/virtualMfaDevice.ts +253 -0
  76. package/providers/aws/management/resourceAssociationConfiguration.ts +112 -0
  77. package/providers/aws/management/resourceAssociationRegistration.ts +349 -0
  78. package/providers/aws/management/resourceAssociations.ts +168 -0
  79. package/{src/providers → providers}/aws/management/resourceConfiguration.ts +24 -26
  80. package/providers/aws/management/resourceLifecycleRegistration.ts +540 -0
  81. package/providers/aws/management/resourceManagementModule.ts +31 -0
  82. package/providers/aws/management/resourceManagementRegistry.ts +62 -0
  83. package/providers/aws/management/resourceMapping.ts +84 -0
  84. package/providers/aws/management/resourceOperation.ts +134 -0
  85. package/providers/aws/management/resourceTagOperations.ts +108 -0
  86. package/providers/aws/management/resourceTiming.ts +4 -0
  87. package/providers/aws/runtime.ts +52 -0
  88. package/src/core/resource/resourceCommandPolicy.ts +20 -0
  89. package/src/core/resource/resourceLifecycle.ts +644 -0
  90. package/src/core/resource/resourceStabilization.ts +120 -0
  91. package/src/core/resource/resourceVersions.ts +102 -0
  92. package/src/core/stack/planner.ts +9 -0
  93. package/src/core/stack/resourceStackLifecycle.ts +36 -3
  94. package/src/core/state/resourceState.ts +6 -4
  95. package/src/core/state/stateStore.ts +57 -10
  96. package/src/providers/file/resourcePolicy.ts +13 -12
  97. package/src/providers/providerRuntimeLayer.ts +5 -2
  98. package/src/providers/resourceCommandPolicyLayer.ts +117 -37
  99. package/src/providers/stripe/management/resourcePolicy.ts +22 -11
  100. package/examples/http-echo/application.ts +0 -87
  101. package/src/providers/aws/client/awsClient.ts +0 -418
  102. package/src/providers/aws/client/awsClientConfig.ts +0 -133
  103. package/src/providers/aws/client/awsClientModel.ts +0 -119
  104. package/src/providers/aws/client/awsHttpOperation.ts +0 -153
  105. package/src/providers/aws/client/awsQueryOperation.ts +0 -149
  106. package/src/providers/aws/client/awsRequestSigner.ts +0 -115
  107. package/src/providers/aws/client/awsResponseDecoder.ts +0 -135
  108. package/src/providers/aws/client/awsRetryPolicy.ts +0 -62
  109. package/src/providers/aws/client/generated/apiGatewayV2.ts +0 -3025
  110. package/src/providers/aws/client/generated/cloudControl.ts +0 -5746
  111. package/src/providers/aws/client/generated/iam.ts +0 -10892
  112. package/src/providers/aws/client/generated/lambda.ts +0 -5403
  113. package/src/providers/aws/client/generated/sqs.ts +0 -3769
  114. package/src/providers/aws/client/generated/stepFunctions.ts +0 -1726
  115. package/src/providers/aws/client/openapi/cloudControl/CancelResourceRequest.json +0 -579
  116. package/src/providers/aws/client/openapi/cloudControl/CreateResource.json +0 -1019
  117. package/src/providers/aws/client/openapi/cloudControl/DeleteResource.json +0 -1018
  118. package/src/providers/aws/client/openapi/cloudControl/GetResource.json +0 -883
  119. package/src/providers/aws/client/openapi/cloudControl/GetResourceRequestStatus.json +0 -655
  120. package/src/providers/aws/client/openapi/cloudControl/ListResourceRequests.json +0 -566
  121. package/src/providers/aws/client/openapi/cloudControl/ListResources.json +0 -913
  122. package/src/providers/aws/client/openapi/cloudControl/UpdateResource.json +0 -1027
  123. package/src/providers/aws/cloudControl/client.ts +0 -69
  124. package/src/providers/aws/cloudControl/requestTracker.ts +0 -138
  125. package/src/providers/aws/cloudControl/resourceCommandPolicyLayer.ts +0 -63
  126. package/src/providers/aws/cloudControl/resourceLifecycle.ts +0 -479
  127. package/src/providers/aws/cloudControl/resources/generated/certificatemanager/certificate/index.ts +0 -179
  128. package/src/providers/aws/cloudControl/resources/generated/kms/key/index.ts +0 -362
  129. package/src/providers/aws/cloudControl/resources/generated/s3/bucket/index.ts +0 -2364
  130. package/src/providers/aws/cloudControl/resources/generated/sns/topic/index.ts +0 -326
  131. package/src/providers/aws/cloudControl/resources/generated/sqs/queue/index.ts +0 -307
  132. package/src/providers/aws/cloudControl/resources/generated/sqs/queueinlinepolicy/index.ts +0 -108
  133. package/src/providers/aws/cloudControl/runtime.ts +0 -127
  134. package/src/providers/aws/management/resourceMapping.ts +0 -343
  135. package/src/providers/aws/management/resourceOperation.ts +0 -57
  136. package/src/providers/aws/management/resourcePolicy.ts +0 -549
  137. package/src/providers/aws/management/resourceRegistration.ts +0 -294
  138. package/src/providers/aws/resources/apiGatewayV2/httpApi.ts +0 -327
  139. package/src/providers/aws/resources/generated/native/resourceCommands.ts +0 -152
  140. package/src/providers/aws/resources/iam/grant.ts +0 -150
  141. package/src/providers/aws/resources/iam/grantCommands.ts +0 -283
  142. package/src/providers/aws/resources/iam/policyDocument.ts +0 -30
  143. package/src/providers/aws/resources/iam/policyStatement.ts +0 -59
  144. package/src/providers/aws/resources/iam/role.ts +0 -426
  145. package/src/providers/aws/resources/iam/roleDeclaration.ts +0 -105
  146. package/src/providers/aws/resources/lambda/function.ts +0 -403
  147. package/src/providers/aws/resources/lambda/functionDeclaration.ts +0 -234
  148. package/src/providers/aws/resources/lambda/permission.ts +0 -363
  149. package/src/providers/aws/resources/stepFunctions/stateMachine.ts +0 -95
  150. package/src/providers/aws/runtime.ts +0 -70
@@ -0,0 +1,63 @@
1
+ import { Group, iamOperations } from "@tradedal/aws-client-iam";
2
+ import { Schema } from "effect";
3
+ import {
4
+ AWSGroupOutputsSchema,
5
+ AWSGroupResourceSchema,
6
+ } from "nomoss/providers/aws/iam/group";
7
+ import {
8
+ type AwsResourceLifecycleMapping,
9
+ AwsResourceLifecycleRegistration,
10
+ } from "../../resourceLifecycleRegistration.js";
11
+ import { resourceRequest, resourceResponse } from "../../resourceOperation.js";
12
+ import { IamGroupId } from "./iamIdentity.js";
13
+ import { iamLifecycleSettings } from "./iamLifecycleSettings.js";
14
+
15
+ const name = { GroupName: Group.schema.fields.GroupName };
16
+ const path = Schema.optionalKey(Group.schema.fields.Path);
17
+
18
+ /**
19
+ * The groupLifecycleMapping definition requires the original GroupId on
20
+ * later commands because IAM can reuse a group name. The stack rejects an
21
+ * update or delete when that name now identifies a different group.
22
+ *
23
+ * @see ../../../../../refs/aws-api-models/models/iam/service/2010-05-08/iam-2010-05-08.json (Group and GetGroup)
24
+ * @see ../../../../../refs/effect/packages/effect/src/Schema.ts (encodeKeys)
25
+ */
26
+ const groupLifecycleMapping = {
27
+ schema: AWSGroupResourceSchema,
28
+ outputsSchema: AWSGroupOutputsSchema,
29
+ generatedName: { property: "GroupName", maxLength: 128 },
30
+ ownership: {
31
+ identity: Schema.Struct({
32
+ ...name,
33
+ GroupId: IamGroupId,
34
+ }),
35
+ property: "GroupId",
36
+ },
37
+ create: resourceResponse(
38
+ resourceRequest(
39
+ iamOperations.CreateGroup,
40
+ Schema.Struct({ ...name, Path: path }),
41
+ ),
42
+ Group,
43
+ ({ Group }) => Group,
44
+ ),
45
+ read: resourceResponse(iamOperations.GetGroup, Group, ({ Group }) => Group),
46
+ update: resourceRequest(
47
+ iamOperations.UpdateGroup,
48
+ Schema.Struct({ ...name, Path: path }).pipe(
49
+ Schema.encodeKeys({ Path: "NewPath" }),
50
+ ),
51
+ ),
52
+ remove: iamOperations.DeleteGroup,
53
+ } satisfies AwsResourceLifecycleMapping;
54
+
55
+ /**
56
+ * The makeGroupManagement constructor registers the group itself. An apply
57
+ * can update its path; use a separate membership declaration to choose
58
+ * which users belong to it.
59
+ */
60
+ export const makeGroupManagement = AwsResourceLifecycleRegistration.make(
61
+ iamLifecycleSettings,
62
+ groupLifecycleMapping,
63
+ );
@@ -0,0 +1,41 @@
1
+ import {
2
+ Group,
3
+ InstanceProfile,
4
+ Policy,
5
+ Role,
6
+ ServerCertificateMetadata,
7
+ User,
8
+ } from "@tradedal/aws-client-iam";
9
+ import { Schema } from "effect";
10
+
11
+ /** The IamGroupId schema identifies the original IAM group even if AWS reuses its name. */
12
+ export const IamGroupId = Group.schema.fields.GroupId.pipe(
13
+ Schema.brand("IamGroupId"),
14
+ );
15
+
16
+ /** The IamRoleId schema separates a role's permanent ID from the name IAM uses to address it. */
17
+ export const IamRoleId = Role.schema.fields.RoleId.pipe(
18
+ Schema.brand("IamRoleId"),
19
+ );
20
+
21
+ /** The IamUserId schema identifies an IAM user even if the user name becomes available again. */
22
+ export const IamUserId = User.schema.fields.UserId.pipe(
23
+ Schema.brand("IamUserId"),
24
+ );
25
+
26
+ /** The IamInstanceProfileId schema distinguishes the profile's permanent identity from the role it can hold. */
27
+ export const IamInstanceProfileId =
28
+ InstanceProfile.schema.fields.InstanceProfileId.pipe(
29
+ Schema.brand("IamInstanceProfileId"),
30
+ );
31
+
32
+ /** The IamPolicyId schema distinguishes policies that IAM creates at the same ARN at different times. */
33
+ export const IamPolicyId = Schema.requiredKey(
34
+ Policy.schema.fields.PolicyId,
35
+ ).pipe(Schema.brand("IamPolicyId"));
36
+
37
+ /** The IamServerCertificateId schema distinguishes a saved upload from a later certificate under the same name. */
38
+ export const IamServerCertificateId =
39
+ ServerCertificateMetadata.schema.fields.ServerCertificateId.pipe(
40
+ Schema.brand("IamServerCertificateId"),
41
+ );
@@ -0,0 +1,8 @@
1
+ import { iamService } from "@tradedal/aws-client-iam";
2
+ import { resourceTiming } from "../../resourceTiming.js";
3
+
4
+ export const iamLifecycleSettings = {
5
+ service: iamService,
6
+ missingErrors: ["NoSuchEntity"],
7
+ timeout: resourceTiming.iam,
8
+ };
@@ -0,0 +1,159 @@
1
+ import {
2
+ GetGroupPolicyResponse,
3
+ GetRolePolicyResponse,
4
+ GetUserPolicyResponse,
5
+ iamOperations,
6
+ PutGroupPolicyRequest,
7
+ PutRolePolicyRequest,
8
+ PutUserPolicyRequest,
9
+ } from "@tradedal/aws-client-iam";
10
+ import { Schema } from "effect";
11
+ import {
12
+ AWSGroupPolicyOutputsSchema,
13
+ AWSGroupPolicyResourceSchema,
14
+ } from "nomoss/providers/aws/iam/grouppolicy";
15
+ import {
16
+ AWSRolePolicyOutputsSchema,
17
+ AWSRolePolicyResourceSchema,
18
+ } from "nomoss/providers/aws/iam/rolepolicy";
19
+ import {
20
+ AWSUserPolicyOutputsSchema,
21
+ AWSUserPolicyResourceSchema,
22
+ } from "nomoss/providers/aws/iam/userpolicy";
23
+ import {
24
+ type AwsResourceLifecycleMapping,
25
+ AwsResourceLifecycleRegistration,
26
+ } from "../../resourceLifecycleRegistration.js";
27
+ import {
28
+ awsJsonDocument,
29
+ awsJsonDocumentInput,
30
+ resourceRequest,
31
+ resourceResponse,
32
+ } from "../../resourceOperation.js";
33
+ import { iamLifecycleSettings } from "./iamLifecycleSettings.js";
34
+
35
+ const createResponse = Schema.Struct({});
36
+
37
+ const putGroupPolicy = resourceRequest(
38
+ iamOperations.PutGroupPolicy,
39
+ PutGroupPolicyRequest.schema.mapFields((fields) => ({
40
+ ...fields,
41
+ PolicyDocument: awsJsonDocumentInput,
42
+ })),
43
+ );
44
+
45
+ const putRolePolicy = resourceRequest(
46
+ iamOperations.PutRolePolicy,
47
+ PutRolePolicyRequest.schema.mapFields((fields) => ({
48
+ ...fields,
49
+ PolicyDocument: awsJsonDocumentInput,
50
+ })),
51
+ );
52
+
53
+ const putUserPolicy = resourceRequest(
54
+ iamOperations.PutUserPolicy,
55
+ PutUserPolicyRequest.schema.mapFields((fields) => ({
56
+ ...fields,
57
+ PolicyDocument: awsJsonDocumentInput,
58
+ })),
59
+ );
60
+
61
+ /**
62
+ * The groupPolicyLifecycleMapping definition identifies an inline policy
63
+ * by the group name and policy name. IAM embeds the document on that group,
64
+ * so the same policy name can refer to a different document on another group.
65
+ *
66
+ * @see ../../../../../refs/aws-api-models/models/iam/service/2010-05-08/iam-2010-05-08.json (PutGroupPolicy)
67
+ */
68
+ const groupPolicyLifecycleMapping = {
69
+ schema: AWSGroupPolicyResourceSchema,
70
+ outputsSchema: AWSGroupPolicyOutputsSchema,
71
+ createMode: "requireAbsent",
72
+ create: resourceResponse(putGroupPolicy, createResponse, () => ({})),
73
+ read: resourceResponse(
74
+ iamOperations.GetGroupPolicy,
75
+ GetGroupPolicyResponse.schema.mapFields((fields) => ({
76
+ ...fields,
77
+ PolicyDocument: awsJsonDocument,
78
+ })),
79
+ ),
80
+ update: putGroupPolicy,
81
+ remove: iamOperations.DeleteGroupPolicy,
82
+ } satisfies AwsResourceLifecycleMapping;
83
+
84
+ /**
85
+ * The rolePolicyLifecycleMapping definition applies to an inline permissions
86
+ * policy. IAM stores the role's trust policy separately, so a change to this
87
+ * document changes the role's permissions and leaves its trust policy intact.
88
+ *
89
+ * @see ../../../../../refs/aws-api-models/models/iam/service/2010-05-08/iam-2010-05-08.json (GetRolePolicy and PutRolePolicy)
90
+ */
91
+ const rolePolicyLifecycleMapping = {
92
+ schema: AWSRolePolicyResourceSchema,
93
+ outputsSchema: AWSRolePolicyOutputsSchema,
94
+ createMode: "requireAbsent",
95
+ create: resourceResponse(putRolePolicy, createResponse, () => ({})),
96
+ read: resourceResponse(
97
+ iamOperations.GetRolePolicy,
98
+ GetRolePolicyResponse.schema.mapFields((fields) => ({
99
+ ...fields,
100
+ PolicyDocument: awsJsonDocument,
101
+ })),
102
+ ),
103
+ update: putRolePolicy,
104
+ remove: iamOperations.DeleteRolePolicy,
105
+ } satisfies AwsResourceLifecycleMapping;
106
+
107
+ /**
108
+ * The userPolicyLifecycleMapping definition requires the user name beside
109
+ * the policy name on reads and deletes. Two IAM users can each have an inline
110
+ * policy with the same name.
111
+ *
112
+ * @see ../../../../../refs/aws-api-models/models/iam/service/2010-05-08/iam-2010-05-08.json (GetUserPolicy and DeleteUserPolicy)
113
+ */
114
+ const userPolicyLifecycleMapping = {
115
+ schema: AWSUserPolicyResourceSchema,
116
+ outputsSchema: AWSUserPolicyOutputsSchema,
117
+ createMode: "requireAbsent",
118
+ create: resourceResponse(putUserPolicy, createResponse, () => ({})),
119
+ read: resourceResponse(
120
+ iamOperations.GetUserPolicy,
121
+ GetUserPolicyResponse.schema.mapFields((fields) => ({
122
+ ...fields,
123
+ PolicyDocument: awsJsonDocument,
124
+ })),
125
+ ),
126
+ update: putUserPolicy,
127
+ remove: iamOperations.DeleteUserPolicy,
128
+ } satisfies AwsResourceLifecycleMapping;
129
+
130
+ /**
131
+ * The makeGroupPolicyManagement constructor registers teardown for an inline
132
+ * group policy. If the group is already absent, IAM's NoSuchEntity response
133
+ * also establishes that its inline policy is absent.
134
+ */
135
+ export const makeGroupPolicyManagement = AwsResourceLifecycleRegistration.make(
136
+ iamLifecycleSettings,
137
+ groupPolicyLifecycleMapping,
138
+ );
139
+
140
+ /**
141
+ * The makeRolePolicyManagement constructor registers a lifecycle that
142
+ * confirms a new policy document through GetRolePolicy. If IAM still returns
143
+ * the previous document after it accepts PutRolePolicy, the stack waits for
144
+ * the read to show the requested permissions.
145
+ */
146
+ export const makeRolePolicyManagement = AwsResourceLifecycleRegistration.make(
147
+ iamLifecycleSettings,
148
+ rolePolicyLifecycleMapping,
149
+ );
150
+
151
+ /**
152
+ * The makeUserPolicyManagement constructor registers a lifecycle for the
153
+ * document attached to one IAM user. If a declaration changes the user name
154
+ * or the policy name, the stack treats it as a different inline policy.
155
+ */
156
+ export const makeUserPolicyManagement = AwsResourceLifecycleRegistration.make(
157
+ iamLifecycleSettings,
158
+ userPolicyLifecycleMapping,
159
+ );
@@ -0,0 +1,77 @@
1
+ import { InstanceProfile, iamOperations, Role } from "@tradedal/aws-client-iam";
2
+ import { Array as Arr, Schema } from "effect";
3
+ import {
4
+ AWSInstanceProfileOutputsSchema,
5
+ AWSInstanceProfileResourceSchema,
6
+ } from "nomoss/providers/aws/iam/instanceprofile";
7
+ import { AssociationNames } from "../../resourceAssociations.js";
8
+ import {
9
+ type AwsResourceLifecycleMapping,
10
+ AwsResourceLifecycleRegistration,
11
+ } from "../../resourceLifecycleRegistration.js";
12
+ import { resourceRequest, resourceResponse } from "../../resourceOperation.js";
13
+ import { IamInstanceProfileId } from "./iamIdentity.js";
14
+ import { iamLifecycleSettings } from "./iamLifecycleSettings.js";
15
+
16
+ const identity = Schema.Struct({
17
+ InstanceProfileName: InstanceProfile.schema.fields.InstanceProfileName,
18
+ InstanceProfileId: IamInstanceProfileId,
19
+ });
20
+
21
+ const membership = Schema.Struct({
22
+ Parent: InstanceProfile.schema.fields.InstanceProfileName,
23
+ Member: Role.schema.fields.RoleName,
24
+ }).pipe(
25
+ Schema.encodeKeys({ Parent: "InstanceProfileName", Member: "RoleName" }),
26
+ );
27
+
28
+ /**
29
+ * The instanceProfile mapping separates the IAM profile request from the
30
+ * role attachment. IAM accepts one role per profile. When the stack replaces
31
+ * that role, it must remove the role it previously declared before it can
32
+ * attach the new one.
33
+ *
34
+ * @see ../../../../../refs/aws-api-models/models/iam/service/2010-05-08/iam-2010-05-08.json (CreateInstanceProfile and AddRoleToInstanceProfile)
35
+ */
36
+ const instanceProfile = {
37
+ schema: AWSInstanceProfileResourceSchema,
38
+ outputsSchema: AWSInstanceProfileOutputsSchema,
39
+ generatedName: { property: "InstanceProfileName", maxLength: 128 },
40
+ ownership: { identity, property: "InstanceProfileId" },
41
+ create: resourceResponse(
42
+ iamOperations.CreateInstanceProfile,
43
+ identity,
44
+ ({ InstanceProfile }) => InstanceProfile,
45
+ ),
46
+ read: resourceResponse(
47
+ iamOperations.GetInstanceProfile,
48
+ InstanceProfile.schema.mapFields((fields) => ({
49
+ ...fields,
50
+ Roles: AssociationNames,
51
+ })),
52
+ ({ InstanceProfile }) => ({
53
+ ...InstanceProfile,
54
+ Roles: Arr.map(InstanceProfile.Roles, ({ RoleName }) => RoleName),
55
+ }),
56
+ ),
57
+ remove: iamOperations.DeleteInstanceProfile,
58
+ associations: {
59
+ property: "Roles",
60
+ parent: "InstanceProfileName",
61
+ capacity: 1,
62
+ order: "releaseSlotFirst",
63
+ add: resourceRequest(iamOperations.AddRoleToInstanceProfile, membership),
64
+ remove: resourceRequest(
65
+ iamOperations.RemoveRoleFromInstanceProfile,
66
+ membership,
67
+ ),
68
+ },
69
+ } satisfies AwsResourceLifecycleMapping;
70
+
71
+ /**
72
+ * The makeInstanceProfileManagement constructor registers a lifecycle for
73
+ * the profile itself. If IAM returns a different profile ID for the saved
74
+ * name, the stack refuses to change the role or delete the replacement.
75
+ */
76
+ export const makeInstanceProfileManagement =
77
+ AwsResourceLifecycleRegistration.make(iamLifecycleSettings, instanceProfile);
@@ -0,0 +1,94 @@
1
+ import {
2
+ CreateOpenIDConnectProviderRequest,
3
+ GetOpenIDConnectProviderRequest,
4
+ GetOpenIDConnectProviderResponse,
5
+ iamOperations,
6
+ UpdateOpenIDConnectProviderThumbprintRequest,
7
+ } from "@tradedal/aws-client-iam";
8
+ import { Schema, SchemaTransformation, String as Str } from "effect";
9
+ import {
10
+ AWSOIDCProviderOutputsSchema,
11
+ AWSOIDCProviderResourceSchema,
12
+ } from "nomoss/providers/aws/iam/oidcprovider";
13
+ import {
14
+ type AwsResourceLifecycleMapping,
15
+ AwsResourceLifecycleRegistration,
16
+ } from "../../resourceLifecycleRegistration.js";
17
+ import { resourceRequest, resourceResponse } from "../../resourceOperation.js";
18
+ import { iamLifecycleSettings } from "./iamLifecycleSettings.js";
19
+
20
+ const identity = Schema.Struct({ Arn: AwsArn }).pipe(
21
+ Schema.encodeKeys({ Arn: "OpenIDConnectProviderArn" }),
22
+ );
23
+
24
+ const { ClientIDList, ...createFields } =
25
+ CreateOpenIDConnectProviderRequest.schema.fields;
26
+
27
+ const {
28
+ ClientIDList: observedClients,
29
+ Url: _url,
30
+ ...observationFields
31
+ } = GetOpenIDConnectProviderResponse.schema.fields;
32
+
33
+ const issuerUrl = Schema.String.pipe(
34
+ Schema.decodeTo(
35
+ Schema.String,
36
+ SchemaTransformation.transform({
37
+ decode: (url) => `https://${url}`,
38
+ encode: Str.replace("https://", ""),
39
+ }),
40
+ ),
41
+ );
42
+
43
+ /**
44
+ * The oidcProviderLifecycleMapping definition restores the HTTPS scheme to
45
+ * the issuer URL because IAM omits it from the read response. The stack
46
+ * can then compare the URL with the one in the declaration.
47
+ *
48
+ * @see ../../../../../refs/aws-api-models/models/iam/service/2010-05-08/iam-2010-05-08.json (GetOpenIDConnectProvider)
49
+ * @see ../../../../../refs/effect/packages/effect/src/Schema.ts (encodeKeys)
50
+ */
51
+ const oidcProviderLifecycleMapping = {
52
+ schema: AWSOIDCProviderResourceSchema,
53
+ outputsSchema: AWSOIDCProviderOutputsSchema,
54
+ create: resourceResponse(
55
+ resourceRequest(
56
+ iamOperations.CreateOpenIDConnectProvider,
57
+ Schema.Struct({ ...createFields, ClientIdList: ClientIDList }).pipe(
58
+ Schema.encodeKeys({ ClientIdList: "ClientIDList" }),
59
+ ),
60
+ ),
61
+ identity,
62
+ ),
63
+ read: resourceResponse(
64
+ resourceRequest(iamOperations.GetOpenIDConnectProvider, identity),
65
+ Schema.Struct({
66
+ ...observationFields,
67
+ Url: Schema.optionalKey(issuerUrl),
68
+ ClientIdList: observedClients,
69
+ }).pipe(Schema.encodeKeys({ ClientIdList: "ClientIDList" })),
70
+ ),
71
+ update: resourceRequest(
72
+ iamOperations.UpdateOpenIDConnectProviderThumbprint,
73
+ Schema.Struct({
74
+ Arn: GetOpenIDConnectProviderRequest.schema.fields
75
+ .OpenIDConnectProviderArn,
76
+ ThumbprintList:
77
+ UpdateOpenIDConnectProviderThumbprintRequest.schema.fields
78
+ .ThumbprintList,
79
+ }).pipe(Schema.encodeKeys({ Arn: "OpenIDConnectProviderArn" })),
80
+ ),
81
+ remove: resourceRequest(iamOperations.DeleteOpenIDConnectProvider, identity),
82
+ } satisfies AwsResourceLifecycleMapping;
83
+
84
+ /**
85
+ * The makeOIDCProviderManagement constructor registers the lifecycle for an
86
+ * IAM OpenID Connect provider. The stack can update its thumbprints and
87
+ * later delete it by the ARN IAM returned at create time.
88
+ */
89
+ export const makeOIDCProviderManagement = AwsResourceLifecycleRegistration.make(
90
+ iamLifecycleSettings,
91
+ oidcProviderLifecycleMapping,
92
+ );
93
+
94
+ import { AwsArn } from "@tradedal/aws-client-core/model";
@@ -0,0 +1,74 @@
1
+ import {
2
+ CreateRoleRequest,
3
+ iamOperations,
4
+ Role,
5
+ UpdateRoleRequest,
6
+ } from "@tradedal/aws-client-iam";
7
+ import { Schema } from "effect";
8
+ import {
9
+ AWSRoleOutputsSchema,
10
+ AWSRoleResourceSchema,
11
+ } from "nomoss/providers/aws/iam/role";
12
+ import {
13
+ type AwsResourceLifecycleMapping,
14
+ AwsResourceLifecycleRegistration,
15
+ } from "../../resourceLifecycleRegistration.js";
16
+ import {
17
+ awsJsonDocument,
18
+ awsJsonDocumentInput,
19
+ resourceRequest,
20
+ resourceResponse,
21
+ } from "../../resourceOperation.js";
22
+ import { IamRoleId } from "./iamIdentity.js";
23
+ import { iamLifecycleSettings } from "./iamLifecycleSettings.js";
24
+
25
+ const identity = Schema.Struct({
26
+ RoleName: Role.schema.fields.RoleName,
27
+ RoleId: IamRoleId,
28
+ });
29
+
30
+ /**
31
+ * The roleLifecycleMapping definition requires the original RoleId because
32
+ * a role name can refer to a different role after deletion. It also exposes
33
+ * the trust policy as a JSON object, so the stack can compare its contents
34
+ * with the policy in the declaration.
35
+ *
36
+ * @see ../../../../../refs/aws-api-models/models/iam/service/2010-05-08/iam-2010-05-08.json (Role and GetRole)
37
+ */
38
+ const roleLifecycleMapping = {
39
+ schema: AWSRoleResourceSchema,
40
+ outputsSchema: AWSRoleOutputsSchema,
41
+ generatedName: { property: "RoleName", maxLength: 64 },
42
+ ownership: { identity, property: "RoleId" },
43
+ create: resourceResponse(
44
+ resourceRequest(
45
+ iamOperations.CreateRole,
46
+ Schema.Struct({
47
+ ...CreateRoleRequest.schema.fields,
48
+ AssumeRolePolicyDocument: awsJsonDocumentInput,
49
+ }),
50
+ ),
51
+ identity,
52
+ ({ Role }) => Role,
53
+ ),
54
+ read: resourceResponse(
55
+ iamOperations.GetRole,
56
+ Schema.Struct({
57
+ ...Role.schema.fields,
58
+ AssumeRolePolicyDocument: Schema.optionalKey(awsJsonDocument),
59
+ }),
60
+ ({ Role }) => Role,
61
+ ),
62
+ update: resourceRequest(iamOperations.UpdateRole, UpdateRoleRequest.schema),
63
+ remove: iamOperations.DeleteRole,
64
+ } satisfies AwsResourceLifecycleMapping;
65
+
66
+ /**
67
+ * The makeRoleManagement constructor registers the IAM role itself.
68
+ * Declare its trust policy at create time. This lifecycle uses UpdateRole
69
+ * for in-place changes such as the description.
70
+ */
71
+ export const makeRoleManagement = AwsResourceLifecycleRegistration.make(
72
+ iamLifecycleSettings,
73
+ roleLifecycleMapping,
74
+ );
@@ -0,0 +1,98 @@
1
+ import {
2
+ CreateSAMLProviderRequest,
3
+ GetSAMLProviderResponse,
4
+ iamOperations,
5
+ UpdateSAMLProviderRequest,
6
+ } from "@tradedal/aws-client-iam";
7
+ import { Schema } from "effect";
8
+ import {
9
+ AWSSAMLProviderOutputsSchema,
10
+ AWSSAMLProviderResourceSchema,
11
+ } from "nomoss/providers/aws/iam/samlprovider";
12
+ import {
13
+ type AwsResourceLifecycleMapping,
14
+ AwsResourceLifecycleRegistration,
15
+ } from "../../resourceLifecycleRegistration.js";
16
+ import { resourceRequest, resourceResponse } from "../../resourceOperation.js";
17
+ import { iamLifecycleSettings } from "./iamLifecycleSettings.js";
18
+
19
+ const identity = Schema.Struct({ Arn: AwsArn }).pipe(
20
+ Schema.encodeKeys({ Arn: "SAMLProviderArn" }),
21
+ );
22
+
23
+ const { SAMLMetadataDocument: metadata, ...createFields } =
24
+ CreateSAMLProviderRequest.schema.fields;
25
+
26
+ const {
27
+ SAMLProviderArn,
28
+ SAMLMetadataDocument: updateMetadata,
29
+ ...updateFields
30
+ } = UpdateSAMLProviderRequest.schema.fields;
31
+
32
+ const {
33
+ SAMLProviderUUID,
34
+ SAMLMetadataDocument: observedMetadata,
35
+ ...readFields
36
+ } = GetSAMLProviderResponse.schema.fields;
37
+
38
+ /**
39
+ * The samlProviderLifecycleMapping definition uses the ARN to read the IAM
40
+ * provider UUID after create. The same read supplies the current metadata
41
+ * and encryption mode, so a successful update request alone cannot confirm
42
+ * the requested values.
43
+ *
44
+ * @see ../../../../../refs/aws-api-models/models/iam/service/2010-05-08/iam-2010-05-08.json (CreateSAMLProvider and GetSAMLProvider)
45
+ * @see ../../../../../refs/effect/packages/effect/src/Schema.ts (encodeKeys)
46
+ */
47
+ const samlProviderLifecycleMapping = {
48
+ schema: AWSSAMLProviderResourceSchema,
49
+ outputsSchema: AWSSAMLProviderOutputsSchema,
50
+ generatedName: { property: "Name", maxLength: 128 },
51
+ create: resourceResponse(
52
+ resourceRequest(
53
+ iamOperations.CreateSAMLProvider,
54
+ Schema.Struct({ ...createFields, SamlMetadataDocument: metadata }).pipe(
55
+ Schema.encodeKeys({ SamlMetadataDocument: "SAMLMetadataDocument" }),
56
+ ),
57
+ ),
58
+ identity,
59
+ ),
60
+ read: resourceResponse(
61
+ resourceRequest(iamOperations.GetSAMLProvider, identity),
62
+ Schema.Struct({
63
+ ...readFields,
64
+ SamlProviderUUID: SAMLProviderUUID,
65
+ SamlMetadataDocument: observedMetadata,
66
+ }).pipe(
67
+ Schema.encodeKeys({
68
+ SamlProviderUUID: "SAMLProviderUUID",
69
+ SamlMetadataDocument: "SAMLMetadataDocument",
70
+ }),
71
+ ),
72
+ ),
73
+ update: resourceRequest(
74
+ iamOperations.UpdateSAMLProvider,
75
+ Schema.Struct({
76
+ Arn: SAMLProviderArn,
77
+ ...updateFields,
78
+ SamlMetadataDocument: updateMetadata,
79
+ }).pipe(
80
+ Schema.encodeKeys({
81
+ Arn: "SAMLProviderArn",
82
+ SamlMetadataDocument: "SAMLMetadataDocument",
83
+ }),
84
+ ),
85
+ ),
86
+ remove: resourceRequest(iamOperations.DeleteSAMLProvider, identity),
87
+ } satisfies AwsResourceLifecycleMapping;
88
+
89
+ /**
90
+ * The makeSAMLProviderManagement constructor registers an IAM SAML provider.
91
+ * The stack can apply a new metadata document to the same provider ARN.
92
+ */
93
+ export const makeSAMLProviderManagement = AwsResourceLifecycleRegistration.make(
94
+ iamLifecycleSettings,
95
+ samlProviderLifecycleMapping,
96
+ );
97
+
98
+ import { AwsArn } from "@tradedal/aws-client-core/model";
@@ -0,0 +1,72 @@
1
+ import {
2
+ iamOperations,
3
+ ServerCertificateMetadata,
4
+ UploadServerCertificateRequest,
5
+ } from "@tradedal/aws-client-iam";
6
+ import { Schema } from "effect";
7
+ import {
8
+ AWSServerCertificateOutputsSchema,
9
+ AWSServerCertificateResourceSchema,
10
+ } from "nomoss/providers/aws/iam/servercertificate";
11
+ import {
12
+ type AwsResourceLifecycleMapping,
13
+ AwsResourceLifecycleRegistration,
14
+ } from "../../resourceLifecycleRegistration.js";
15
+ import { resourceRequest, resourceResponse } from "../../resourceOperation.js";
16
+ import { IamServerCertificateId } from "./iamIdentity.js";
17
+ import { iamLifecycleSettings } from "./iamLifecycleSettings.js";
18
+
19
+ const { ServerCertificateName, Path } = ServerCertificateMetadata.schema.fields;
20
+
21
+ /**
22
+ * The serverCertificateLifecycleMapping definition confirms an upload with
23
+ * the certificate metadata IAM returns. Later commands check the saved
24
+ * certificate ID so a different upload under the same name remains intact.
25
+ *
26
+ * @see ../../../../../refs/aws-api-models/models/iam/service/2010-05-08/iam-2010-05-08.json (UploadServerCertificate and ServerCertificateMetadata)
27
+ * @see ../../../../../refs/effect/packages/effect/src/Schema.ts (encodeKeys)
28
+ */
29
+ const serverCertificateLifecycleMapping = {
30
+ schema: AWSServerCertificateResourceSchema,
31
+ outputsSchema: AWSServerCertificateOutputsSchema,
32
+ generatedName: { property: "ServerCertificateName", maxLength: 128 },
33
+ ownership: {
34
+ identity: Schema.Struct({
35
+ ServerCertificateName,
36
+ ServerCertificateId: IamServerCertificateId,
37
+ }),
38
+ property: "ServerCertificateId",
39
+ },
40
+ create: resourceResponse(
41
+ resourceRequest(
42
+ iamOperations.UploadServerCertificate,
43
+ UploadServerCertificateRequest.schema,
44
+ ),
45
+ ServerCertificateMetadata,
46
+ ({ ServerCertificateMetadata }) => ServerCertificateMetadata,
47
+ ),
48
+ read: resourceResponse(
49
+ iamOperations.GetServerCertificate,
50
+ ServerCertificateMetadata,
51
+ ({ ServerCertificate }) => ServerCertificate?.ServerCertificateMetadata,
52
+ ),
53
+ update: resourceRequest(
54
+ iamOperations.UpdateServerCertificate,
55
+ Schema.Struct({
56
+ ServerCertificateName,
57
+ Path: Schema.optionalKey(Path),
58
+ }).pipe(Schema.encodeKeys({ Path: "NewPath" })),
59
+ ),
60
+ remove: iamOperations.DeleteServerCertificate,
61
+ } satisfies AwsResourceLifecycleMapping;
62
+
63
+ /**
64
+ * The makeServerCertificateManagement constructor registers a certificate
65
+ * uploaded to IAM. It can change the certificate's path in place. Supply
66
+ * a replacement resource to upload a different certificate or private key.
67
+ */
68
+ export const makeServerCertificateManagement =
69
+ AwsResourceLifecycleRegistration.make(
70
+ iamLifecycleSettings,
71
+ serverCertificateLifecycleMapping,
72
+ );