alchemy 2.0.0-beta.10 → 2.0.0-beta.13

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 (420) hide show
  1. package/bin/alchemy.js +1122 -450
  2. package/bin/alchemy.js.map +1 -1
  3. package/bin/alchemy.sh +15 -0
  4. package/bin/alchemy.ts +22 -727
  5. package/bin/commands/_shared.ts +237 -0
  6. package/bin/commands/bootstrap.ts +117 -0
  7. package/bin/commands/deploy.ts +144 -0
  8. package/bin/commands/login.ts +93 -0
  9. package/bin/commands/logs.ts +157 -0
  10. package/bin/commands/tail.ts +138 -0
  11. package/lib/AWS/AuthProvider.d.ts +7 -71
  12. package/lib/AWS/AuthProvider.d.ts.map +1 -1
  13. package/lib/AWS/AuthProvider.js +27 -22
  14. package/lib/AWS/AuthProvider.js.map +1 -1
  15. package/lib/AWS/AutoScaling/LaunchTemplate.d.ts +3 -3
  16. package/lib/AWS/AutoScaling/LaunchTemplate.d.ts.map +1 -1
  17. package/lib/AWS/AutoScaling/LaunchTemplate.js +2 -2
  18. package/lib/AWS/AutoScaling/LaunchTemplate.js.map +1 -1
  19. package/lib/AWS/Bootstrap.d.ts +2 -1
  20. package/lib/AWS/Bootstrap.d.ts.map +1 -1
  21. package/lib/AWS/Bootstrap.js +27 -29
  22. package/lib/AWS/Bootstrap.js.map +1 -1
  23. package/lib/AWS/CloudWatch/Alarm.d.ts +2 -2
  24. package/lib/AWS/CloudWatch/Alarm.d.ts.map +1 -1
  25. package/lib/AWS/CloudWatch/Alarm.js +2 -2
  26. package/lib/AWS/CloudWatch/Alarm.js.map +1 -1
  27. package/lib/AWS/CloudWatch/AlarmMuteRule.d.ts +2 -2
  28. package/lib/AWS/CloudWatch/AlarmMuteRule.d.ts.map +1 -1
  29. package/lib/AWS/CloudWatch/AlarmMuteRule.js +2 -2
  30. package/lib/AWS/CloudWatch/AlarmMuteRule.js.map +1 -1
  31. package/lib/AWS/CloudWatch/CompositeAlarm.d.ts +2 -2
  32. package/lib/AWS/CloudWatch/CompositeAlarm.d.ts.map +1 -1
  33. package/lib/AWS/CloudWatch/CompositeAlarm.js +2 -2
  34. package/lib/AWS/CloudWatch/CompositeAlarm.js.map +1 -1
  35. package/lib/AWS/CloudWatch/Dashboard.d.ts +2 -2
  36. package/lib/AWS/CloudWatch/Dashboard.d.ts.map +1 -1
  37. package/lib/AWS/CloudWatch/Dashboard.js +2 -2
  38. package/lib/AWS/CloudWatch/Dashboard.js.map +1 -1
  39. package/lib/AWS/CloudWatch/InsightRule.d.ts +2 -2
  40. package/lib/AWS/CloudWatch/InsightRule.d.ts.map +1 -1
  41. package/lib/AWS/CloudWatch/InsightRule.js +2 -2
  42. package/lib/AWS/CloudWatch/InsightRule.js.map +1 -1
  43. package/lib/AWS/CloudWatch/MetricStream.d.ts +2 -2
  44. package/lib/AWS/CloudWatch/MetricStream.d.ts.map +1 -1
  45. package/lib/AWS/CloudWatch/MetricStream.js +2 -2
  46. package/lib/AWS/CloudWatch/MetricStream.js.map +1 -1
  47. package/lib/AWS/Credentials.d.ts +5 -10
  48. package/lib/AWS/Credentials.d.ts.map +1 -1
  49. package/lib/AWS/Credentials.js +6 -30
  50. package/lib/AWS/Credentials.js.map +1 -1
  51. package/lib/AWS/DynamoDB/Table.d.ts +1 -1
  52. package/lib/AWS/DynamoDB/Table.d.ts.map +1 -1
  53. package/lib/AWS/EC2/EIP.d.ts +3 -3
  54. package/lib/AWS/EC2/EIP.d.ts.map +1 -1
  55. package/lib/AWS/EC2/EIP.js +2 -2
  56. package/lib/AWS/EC2/EIP.js.map +1 -1
  57. package/lib/AWS/EC2/EgressOnlyInternetGateway.d.ts +3 -3
  58. package/lib/AWS/EC2/EgressOnlyInternetGateway.d.ts.map +1 -1
  59. package/lib/AWS/EC2/EgressOnlyInternetGateway.js +2 -2
  60. package/lib/AWS/EC2/EgressOnlyInternetGateway.js.map +1 -1
  61. package/lib/AWS/EC2/Instance.d.ts +3 -3
  62. package/lib/AWS/EC2/Instance.d.ts.map +1 -1
  63. package/lib/AWS/EC2/Instance.js +2 -2
  64. package/lib/AWS/EC2/Instance.js.map +1 -1
  65. package/lib/AWS/EC2/InternetGateway.d.ts +3 -3
  66. package/lib/AWS/EC2/InternetGateway.d.ts.map +1 -1
  67. package/lib/AWS/EC2/InternetGateway.js +2 -2
  68. package/lib/AWS/EC2/InternetGateway.js.map +1 -1
  69. package/lib/AWS/EC2/NatGateway.d.ts +3 -3
  70. package/lib/AWS/EC2/NatGateway.d.ts.map +1 -1
  71. package/lib/AWS/EC2/NatGateway.js +2 -2
  72. package/lib/AWS/EC2/NatGateway.js.map +1 -1
  73. package/lib/AWS/EC2/Network.d.ts +1 -1
  74. package/lib/AWS/EC2/NetworkAcl.d.ts +3 -3
  75. package/lib/AWS/EC2/NetworkAcl.d.ts.map +1 -1
  76. package/lib/AWS/EC2/NetworkAcl.js +2 -2
  77. package/lib/AWS/EC2/NetworkAcl.js.map +1 -1
  78. package/lib/AWS/EC2/RouteTable.d.ts +3 -3
  79. package/lib/AWS/EC2/RouteTable.d.ts.map +1 -1
  80. package/lib/AWS/EC2/RouteTable.js +2 -2
  81. package/lib/AWS/EC2/RouteTable.js.map +1 -1
  82. package/lib/AWS/EC2/SecurityGroup.d.ts +3 -3
  83. package/lib/AWS/EC2/SecurityGroup.d.ts.map +1 -1
  84. package/lib/AWS/EC2/SecurityGroup.js +2 -2
  85. package/lib/AWS/EC2/SecurityGroup.js.map +1 -1
  86. package/lib/AWS/EC2/Subnet.d.ts +1 -1
  87. package/lib/AWS/EC2/Subnet.d.ts.map +1 -1
  88. package/lib/AWS/EC2/Vpc.d.ts +3 -3
  89. package/lib/AWS/EC2/Vpc.d.ts.map +1 -1
  90. package/lib/AWS/EC2/Vpc.js +2 -2
  91. package/lib/AWS/EC2/Vpc.js.map +1 -1
  92. package/lib/AWS/EC2/VpcEndpoint.d.ts +3 -3
  93. package/lib/AWS/EC2/VpcEndpoint.d.ts.map +1 -1
  94. package/lib/AWS/EC2/VpcEndpoint.js +2 -2
  95. package/lib/AWS/EC2/VpcEndpoint.js.map +1 -1
  96. package/lib/AWS/ECR/Repository.d.ts +1 -1
  97. package/lib/AWS/ECR/Repository.d.ts.map +1 -1
  98. package/lib/AWS/ECR/Repository.js +0 -1
  99. package/lib/AWS/ECR/Repository.js.map +1 -1
  100. package/lib/AWS/ECS/Cluster.d.ts +2 -2
  101. package/lib/AWS/ECS/Cluster.d.ts.map +1 -1
  102. package/lib/AWS/ECS/Cluster.js +2 -2
  103. package/lib/AWS/ECS/Cluster.js.map +1 -1
  104. package/lib/AWS/ECS/Service.d.ts +1 -1
  105. package/lib/AWS/ECS/Service.d.ts.map +1 -1
  106. package/lib/AWS/ECS/Task.d.ts +2 -2
  107. package/lib/AWS/ECS/Task.d.ts.map +1 -1
  108. package/lib/AWS/ECS/Task.js +2 -2
  109. package/lib/AWS/ECS/Task.js.map +1 -1
  110. package/lib/AWS/EKS/Cluster.d.ts +1 -1
  111. package/lib/AWS/EKS/Cluster.d.ts.map +1 -1
  112. package/lib/AWS/ELBv2/Listener.d.ts +1 -1
  113. package/lib/AWS/ELBv2/Listener.d.ts.map +1 -1
  114. package/lib/AWS/ELBv2/LoadBalancer.d.ts +1 -1
  115. package/lib/AWS/ELBv2/LoadBalancer.d.ts.map +1 -1
  116. package/lib/AWS/ELBv2/TargetGroup.d.ts +1 -1
  117. package/lib/AWS/ELBv2/TargetGroup.d.ts.map +1 -1
  118. package/lib/AWS/Endpoint.d.ts +7 -2
  119. package/lib/AWS/Endpoint.d.ts.map +1 -1
  120. package/lib/AWS/Endpoint.js +7 -2
  121. package/lib/AWS/Endpoint.js.map +1 -1
  122. package/lib/AWS/Environment.d.ts +68 -0
  123. package/lib/AWS/Environment.d.ts.map +1 -0
  124. package/lib/AWS/Environment.js +53 -0
  125. package/lib/AWS/Environment.js.map +1 -0
  126. package/lib/AWS/EventBridge/EventBus.d.ts +2 -2
  127. package/lib/AWS/EventBridge/EventBus.d.ts.map +1 -1
  128. package/lib/AWS/EventBridge/EventBus.js +2 -2
  129. package/lib/AWS/EventBridge/EventBus.js.map +1 -1
  130. package/lib/AWS/EventBridge/ListRules.d.ts +2 -2
  131. package/lib/AWS/EventBridge/ListRules.d.ts.map +1 -1
  132. package/lib/AWS/EventBridge/ListRules.js +2 -2
  133. package/lib/AWS/EventBridge/ListRules.js.map +1 -1
  134. package/lib/AWS/EventBridge/PutEvents.d.ts +2 -2
  135. package/lib/AWS/EventBridge/PutEvents.d.ts.map +1 -1
  136. package/lib/AWS/EventBridge/PutEvents.js +2 -2
  137. package/lib/AWS/EventBridge/PutEvents.js.map +1 -1
  138. package/lib/AWS/EventBridge/Rule.d.ts +2 -2
  139. package/lib/AWS/EventBridge/Rule.d.ts.map +1 -1
  140. package/lib/AWS/EventBridge/Rule.js +2 -2
  141. package/lib/AWS/EventBridge/Rule.js.map +1 -1
  142. package/lib/AWS/IAM/OpenIDConnectProvider.d.ts +2 -2
  143. package/lib/AWS/IAM/OpenIDConnectProvider.d.ts.map +1 -1
  144. package/lib/AWS/IAM/OpenIDConnectProvider.js +2 -2
  145. package/lib/AWS/IAM/OpenIDConnectProvider.js.map +1 -1
  146. package/lib/AWS/IAM/Policy.d.ts +3 -3
  147. package/lib/AWS/IAM/Policy.d.ts.map +1 -1
  148. package/lib/AWS/IAM/Policy.js +2 -2
  149. package/lib/AWS/IAM/Policy.js.map +1 -1
  150. package/lib/AWS/IAM/Role.d.ts +3 -3
  151. package/lib/AWS/IAM/Role.d.ts.map +1 -1
  152. package/lib/AWS/IAM/Role.js +3 -3
  153. package/lib/AWS/IAM/Role.js.map +1 -1
  154. package/lib/AWS/Kinesis/Stream.d.ts +2 -2
  155. package/lib/AWS/Kinesis/Stream.d.ts.map +1 -1
  156. package/lib/AWS/Kinesis/Stream.js +2 -2
  157. package/lib/AWS/Kinesis/Stream.js.map +1 -1
  158. package/lib/AWS/Lambda/BucketEventSource.d.ts +1 -1
  159. package/lib/AWS/Lambda/BucketEventSource.d.ts.map +1 -1
  160. package/lib/AWS/Lambda/EventBridgeEventSource.d.ts +1 -1
  161. package/lib/AWS/Lambda/EventBridgeEventSource.d.ts.map +1 -1
  162. package/lib/AWS/Lambda/EventSourceMapping.d.ts +2 -2
  163. package/lib/AWS/Lambda/EventSourceMapping.d.ts.map +1 -1
  164. package/lib/AWS/Lambda/EventSourceMapping.js +2 -2
  165. package/lib/AWS/Lambda/EventSourceMapping.js.map +1 -1
  166. package/lib/AWS/Lambda/Function.d.ts +2 -2
  167. package/lib/AWS/Lambda/Function.d.ts.map +1 -1
  168. package/lib/AWS/Lambda/Function.js +2 -2
  169. package/lib/AWS/Lambda/Function.js.map +1 -1
  170. package/lib/AWS/Lambda/Permission.d.ts +1 -1
  171. package/lib/AWS/Lambda/Permission.js +1 -1
  172. package/lib/AWS/Lambda/QueueEventSource.d.ts +1 -1
  173. package/lib/AWS/Lambda/QueueEventSource.d.ts.map +1 -1
  174. package/lib/AWS/Lambda/StreamEventSource.d.ts +1 -1
  175. package/lib/AWS/Lambda/StreamEventSource.d.ts.map +1 -1
  176. package/lib/AWS/Lambda/TableEventSource.d.ts +1 -1
  177. package/lib/AWS/Lambda/TableEventSource.d.ts.map +1 -1
  178. package/lib/AWS/Lambda/TopicEventSource.d.ts +1 -1
  179. package/lib/AWS/Lambda/TopicEventSource.d.ts.map +1 -1
  180. package/lib/AWS/Logs/LogGroup.d.ts +3 -3
  181. package/lib/AWS/Logs/LogGroup.d.ts.map +1 -1
  182. package/lib/AWS/Logs/LogGroup.js +2 -2
  183. package/lib/AWS/Logs/LogGroup.js.map +1 -1
  184. package/lib/AWS/Providers.d.ts +1 -2
  185. package/lib/AWS/Providers.d.ts.map +1 -1
  186. package/lib/AWS/Providers.js +3 -3
  187. package/lib/AWS/Providers.js.map +1 -1
  188. package/lib/AWS/Region.d.ts +6 -22
  189. package/lib/AWS/Region.d.ts.map +1 -1
  190. package/lib/AWS/Region.js +6 -39
  191. package/lib/AWS/Region.js.map +1 -1
  192. package/lib/AWS/S3/Bucket.d.ts +2 -2
  193. package/lib/AWS/S3/Bucket.d.ts.map +1 -1
  194. package/lib/AWS/S3/Bucket.js +2 -2
  195. package/lib/AWS/S3/Bucket.js.map +1 -1
  196. package/lib/AWS/SNS/Topic.d.ts +1 -1
  197. package/lib/AWS/SNS/Topic.d.ts.map +1 -1
  198. package/lib/AWS/SQS/Queue.d.ts +3 -3
  199. package/lib/AWS/SQS/Queue.d.ts.map +1 -1
  200. package/lib/AWS/SQS/Queue.js +2 -2
  201. package/lib/AWS/SQS/Queue.js.map +1 -1
  202. package/lib/AWS/index.d.ts +1 -3
  203. package/lib/AWS/index.d.ts.map +1 -1
  204. package/lib/AWS/index.js +1 -3
  205. package/lib/AWS/index.js.map +1 -1
  206. package/lib/Apply.d.ts.map +1 -1
  207. package/lib/Apply.js +2 -2
  208. package/lib/Apply.js.map +1 -1
  209. package/lib/Auth/AuthProvider.d.ts +51 -7
  210. package/lib/Auth/AuthProvider.d.ts.map +1 -1
  211. package/lib/Auth/AuthProvider.js +37 -0
  212. package/lib/Auth/AuthProvider.js.map +1 -1
  213. package/lib/Auth/Profile.d.ts +71 -10
  214. package/lib/Auth/Profile.d.ts.map +1 -1
  215. package/lib/Auth/Profile.js +47 -30
  216. package/lib/Auth/Profile.js.map +1 -1
  217. package/lib/Auth/index.d.ts +1 -1
  218. package/lib/Auth/index.d.ts.map +1 -1
  219. package/lib/Cloudflare/Auth/AuthProvider.d.ts +14 -31
  220. package/lib/Cloudflare/Auth/AuthProvider.d.ts.map +1 -1
  221. package/lib/Cloudflare/Auth/AuthProvider.js +59 -38
  222. package/lib/Cloudflare/Auth/AuthProvider.js.map +1 -1
  223. package/lib/Cloudflare/CloudflareEnvironment.d.ts +11 -0
  224. package/lib/Cloudflare/CloudflareEnvironment.d.ts.map +1 -0
  225. package/lib/Cloudflare/CloudflareEnvironment.js +26 -0
  226. package/lib/Cloudflare/CloudflareEnvironment.js.map +1 -0
  227. package/lib/Cloudflare/Container/ContainerApplication.d.ts +70 -42
  228. package/lib/Cloudflare/Container/ContainerApplication.d.ts.map +1 -1
  229. package/lib/Cloudflare/Container/ContainerApplication.js +49 -24
  230. package/lib/Cloudflare/Container/ContainerApplication.js.map +1 -1
  231. package/lib/Cloudflare/Credentials.d.ts +11 -0
  232. package/lib/Cloudflare/Credentials.d.ts.map +1 -0
  233. package/lib/Cloudflare/Credentials.js +34 -0
  234. package/lib/Cloudflare/Credentials.js.map +1 -0
  235. package/lib/Cloudflare/D1/D1Database.d.ts +2 -2
  236. package/lib/Cloudflare/D1/D1Database.d.ts.map +1 -1
  237. package/lib/Cloudflare/D1/D1Database.js +2 -2
  238. package/lib/Cloudflare/D1/D1Database.js.map +1 -1
  239. package/lib/Cloudflare/KV/KVNamespace.d.ts +2 -2
  240. package/lib/Cloudflare/KV/KVNamespace.d.ts.map +1 -1
  241. package/lib/Cloudflare/KV/KVNamespace.js +2 -2
  242. package/lib/Cloudflare/KV/KVNamespace.js.map +1 -1
  243. package/lib/Cloudflare/Providers.d.ts +2 -3
  244. package/lib/Cloudflare/Providers.d.ts.map +1 -1
  245. package/lib/Cloudflare/Providers.js +12 -4
  246. package/lib/Cloudflare/Providers.js.map +1 -1
  247. package/lib/Cloudflare/Queue/Queue.d.ts +52 -0
  248. package/lib/Cloudflare/Queue/Queue.d.ts.map +1 -0
  249. package/lib/Cloudflare/Queue/Queue.js +136 -0
  250. package/lib/Cloudflare/Queue/Queue.js.map +1 -0
  251. package/lib/Cloudflare/Queue/QueueBinding.d.ts +35 -0
  252. package/lib/Cloudflare/Queue/QueueBinding.d.ts.map +1 -0
  253. package/lib/Cloudflare/Queue/QueueBinding.js +51 -0
  254. package/lib/Cloudflare/Queue/QueueBinding.js.map +1 -0
  255. package/lib/Cloudflare/Queue/QueueConsumer.d.ts +86 -0
  256. package/lib/Cloudflare/Queue/QueueConsumer.d.ts.map +1 -0
  257. package/lib/Cloudflare/Queue/QueueConsumer.js +138 -0
  258. package/lib/Cloudflare/Queue/QueueConsumer.js.map +1 -0
  259. package/lib/Cloudflare/Queue/index.d.ts +4 -0
  260. package/lib/Cloudflare/Queue/index.d.ts.map +1 -0
  261. package/lib/Cloudflare/Queue/index.js +4 -0
  262. package/lib/Cloudflare/Queue/index.js.map +1 -0
  263. package/lib/Cloudflare/R2/R2Bucket.d.ts +2 -2
  264. package/lib/Cloudflare/R2/R2Bucket.d.ts.map +1 -1
  265. package/lib/Cloudflare/R2/R2Bucket.js +2 -2
  266. package/lib/Cloudflare/R2/R2Bucket.js.map +1 -1
  267. package/lib/Cloudflare/SecretsStore/Secret.d.ts +74 -0
  268. package/lib/Cloudflare/SecretsStore/Secret.d.ts.map +1 -0
  269. package/lib/Cloudflare/SecretsStore/Secret.js +161 -0
  270. package/lib/Cloudflare/SecretsStore/Secret.js.map +1 -0
  271. package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts +42 -0
  272. package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts.map +1 -0
  273. package/lib/Cloudflare/SecretsStore/SecretBinding.js +49 -0
  274. package/lib/Cloudflare/SecretsStore/SecretBinding.js.map +1 -0
  275. package/lib/Cloudflare/SecretsStore/SecretsStore.d.ts +37 -0
  276. package/lib/Cloudflare/SecretsStore/SecretsStore.d.ts.map +1 -0
  277. package/lib/Cloudflare/SecretsStore/SecretsStore.js +88 -0
  278. package/lib/Cloudflare/SecretsStore/SecretsStore.js.map +1 -0
  279. package/lib/Cloudflare/SecretsStore/index.d.ts +4 -0
  280. package/lib/Cloudflare/SecretsStore/index.d.ts.map +1 -0
  281. package/lib/Cloudflare/SecretsStore/index.js +4 -0
  282. package/lib/Cloudflare/SecretsStore/index.js.map +1 -0
  283. package/lib/Cloudflare/Workers/InferEnv.d.ts +1 -1
  284. package/lib/Cloudflare/Workers/InferEnv.d.ts.map +1 -1
  285. package/lib/Cloudflare/Workers/Worker.d.ts +5 -3
  286. package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
  287. package/lib/Cloudflare/Workers/Worker.js +61 -7
  288. package/lib/Cloudflare/Workers/Worker.js.map +1 -1
  289. package/lib/Cloudflare/Workers/Workflow.d.ts +10 -4
  290. package/lib/Cloudflare/Workers/Workflow.d.ts.map +1 -1
  291. package/lib/Cloudflare/Workers/Workflow.js +3 -3
  292. package/lib/Cloudflare/Workers/Workflow.js.map +1 -1
  293. package/lib/Cloudflare/index.d.ts +3 -1
  294. package/lib/Cloudflare/index.d.ts.map +1 -1
  295. package/lib/Cloudflare/index.js +3 -1
  296. package/lib/Cloudflare/index.js.map +1 -1
  297. package/lib/Stack.d.ts +3 -2
  298. package/lib/Stack.d.ts.map +1 -1
  299. package/lib/Stack.js +10 -7
  300. package/lib/Stack.js.map +1 -1
  301. package/lib/State/LocalState.d.ts.map +1 -1
  302. package/lib/State/LocalState.js +40 -12
  303. package/lib/State/LocalState.js.map +1 -1
  304. package/lib/Test/Bun.d.ts.map +1 -1
  305. package/lib/Test/Bun.js +3 -2
  306. package/lib/Test/Bun.js.map +1 -1
  307. package/lib/Test/Vitest.d.ts +3 -1
  308. package/lib/Test/Vitest.d.ts.map +1 -1
  309. package/lib/Test/Vitest.js +19 -16
  310. package/lib/Test/Vitest.js.map +1 -1
  311. package/lib/Util/PlatformServices.d.ts +14 -3
  312. package/lib/Util/PlatformServices.d.ts.map +1 -1
  313. package/lib/Util/PlatformServices.js +21 -3
  314. package/lib/Util/PlatformServices.js.map +1 -1
  315. package/package.json +5 -5
  316. package/src/AWS/AuthProvider.ts +67 -67
  317. package/src/AWS/AutoScaling/LaunchTemplate.ts +3 -3
  318. package/src/AWS/Bootstrap.ts +32 -37
  319. package/src/AWS/CloudWatch/Alarm.ts +2 -2
  320. package/src/AWS/CloudWatch/AlarmMuteRule.ts +2 -2
  321. package/src/AWS/CloudWatch/CompositeAlarm.ts +2 -2
  322. package/src/AWS/CloudWatch/Dashboard.ts +2 -2
  323. package/src/AWS/CloudWatch/InsightRule.ts +2 -2
  324. package/src/AWS/CloudWatch/MetricStream.ts +2 -2
  325. package/src/AWS/Credentials.ts +9 -44
  326. package/src/AWS/DynamoDB/Table.ts +1 -1
  327. package/src/AWS/EC2/EIP.ts +3 -3
  328. package/src/AWS/EC2/EgressOnlyInternetGateway.ts +3 -3
  329. package/src/AWS/EC2/Instance.ts +3 -3
  330. package/src/AWS/EC2/InternetGateway.ts +3 -3
  331. package/src/AWS/EC2/NatGateway.ts +3 -3
  332. package/src/AWS/EC2/NetworkAcl.ts +3 -3
  333. package/src/AWS/EC2/RouteTable.ts +3 -3
  334. package/src/AWS/EC2/SecurityGroup.ts +3 -3
  335. package/src/AWS/EC2/Subnet.ts +1 -1
  336. package/src/AWS/EC2/Vpc.ts +3 -3
  337. package/src/AWS/EC2/VpcEndpoint.ts +3 -3
  338. package/src/AWS/ECR/Repository.ts +1 -1
  339. package/src/AWS/ECS/Cluster.ts +2 -2
  340. package/src/AWS/ECS/Service.ts +1 -1
  341. package/src/AWS/ECS/Task.ts +2 -2
  342. package/src/AWS/EKS/Cluster.ts +1 -1
  343. package/src/AWS/ELBv2/Listener.ts +1 -1
  344. package/src/AWS/ELBv2/LoadBalancer.ts +1 -1
  345. package/src/AWS/ELBv2/TargetGroup.ts +1 -1
  346. package/src/AWS/Endpoint.ts +12 -8
  347. package/src/AWS/Environment.ts +123 -0
  348. package/src/AWS/EventBridge/EventBus.ts +2 -2
  349. package/src/AWS/EventBridge/ListRules.ts +2 -2
  350. package/src/AWS/EventBridge/PutEvents.ts +2 -2
  351. package/src/AWS/EventBridge/Rule.ts +2 -2
  352. package/src/AWS/IAM/OpenIDConnectProvider.ts +2 -2
  353. package/src/AWS/IAM/Policy.ts +3 -3
  354. package/src/AWS/IAM/Role.ts +4 -4
  355. package/src/AWS/Kinesis/Stream.ts +2 -2
  356. package/src/AWS/Lambda/EventSourceMapping.ts +2 -2
  357. package/src/AWS/Lambda/Function.ts +2 -2
  358. package/src/AWS/Lambda/Permission.ts +1 -1
  359. package/src/AWS/Logs/LogGroup.ts +3 -3
  360. package/src/AWS/Providers.ts +7 -7
  361. package/src/AWS/Region.ts +9 -66
  362. package/src/AWS/S3/Bucket.ts +2 -2
  363. package/src/AWS/SNS/Topic.ts +1 -1
  364. package/src/AWS/SQS/Queue.ts +3 -3
  365. package/src/AWS/index.ts +1 -3
  366. package/src/Apply.ts +55 -57
  367. package/src/Auth/AuthProvider.ts +188 -8
  368. package/src/Auth/Profile.ts +117 -54
  369. package/src/Auth/index.ts +1 -1
  370. package/src/Cloudflare/Auth/AuthProvider.ts +127 -98
  371. package/src/Cloudflare/CloudflareEnvironment.ts +49 -0
  372. package/src/Cloudflare/Container/ContainerApplication.ts +172 -94
  373. package/src/Cloudflare/Credentials.ts +75 -0
  374. package/src/Cloudflare/D1/D1Database.ts +2 -2
  375. package/src/Cloudflare/KV/KVNamespace.ts +2 -2
  376. package/src/Cloudflare/Providers.ts +20 -10
  377. package/src/Cloudflare/Queue/Queue.ts +174 -0
  378. package/src/Cloudflare/Queue/QueueBinding.ts +110 -0
  379. package/src/Cloudflare/Queue/QueueConsumer.ts +219 -0
  380. package/src/Cloudflare/Queue/index.ts +3 -0
  381. package/src/Cloudflare/R2/R2Bucket.ts +2 -2
  382. package/src/Cloudflare/SecretsStore/Secret.ts +229 -0
  383. package/src/Cloudflare/SecretsStore/SecretBinding.ts +107 -0
  384. package/src/Cloudflare/SecretsStore/SecretsStore.ts +106 -0
  385. package/src/Cloudflare/SecretsStore/index.ts +3 -0
  386. package/src/Cloudflare/Workers/InferEnv.ts +5 -3
  387. package/src/Cloudflare/Workers/Worker.ts +63 -7
  388. package/src/Cloudflare/Workers/Workflow.ts +19 -9
  389. package/src/Cloudflare/index.ts +3 -1
  390. package/src/Stack.ts +40 -29
  391. package/src/State/LocalState.ts +43 -16
  392. package/src/Test/Bun.ts +3 -0
  393. package/src/Test/Vitest.ts +31 -23
  394. package/src/Util/PlatformServices.ts +54 -13
  395. package/bin/process-manager.ts +0 -10
  396. package/lib/AWS/Account.d.ts +0 -26
  397. package/lib/AWS/Account.d.ts.map +0 -1
  398. package/lib/AWS/Account.js +0 -32
  399. package/lib/AWS/Account.js.map +0 -1
  400. package/lib/AWS/Profile.d.ts +0 -6
  401. package/lib/AWS/Profile.d.ts.map +0 -1
  402. package/lib/AWS/Profile.js +0 -4
  403. package/lib/AWS/Profile.js.map +0 -1
  404. package/lib/AWS/StageConfig.d.ts +0 -25
  405. package/lib/AWS/StageConfig.d.ts.map +0 -1
  406. package/lib/AWS/StageConfig.js +0 -23
  407. package/lib/AWS/StageConfig.js.map +0 -1
  408. package/lib/Cloudflare/Account.d.ts +0 -10
  409. package/lib/Cloudflare/Account.d.ts.map +0 -1
  410. package/lib/Cloudflare/Account.js +0 -24
  411. package/lib/Cloudflare/Account.js.map +0 -1
  412. package/lib/Cloudflare/StageConfig.d.ts +0 -8
  413. package/lib/Cloudflare/StageConfig.d.ts.map +0 -1
  414. package/lib/Cloudflare/StageConfig.js +0 -4
  415. package/lib/Cloudflare/StageConfig.js.map +0 -1
  416. package/src/AWS/Account.ts +0 -56
  417. package/src/AWS/Profile.ts +0 -5
  418. package/src/AWS/StageConfig.ts +0 -44
  419. package/src/Cloudflare/Account.ts +0 -38
  420. package/src/Cloudflare/StageConfig.ts +0 -8
@@ -1,16 +1,20 @@
1
1
  import { Endpoint } from "@distilled.cloud/aws";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Layer from "effect/Layer";
4
- import { StageConfig } from "./StageConfig.ts";
4
+ import { AWSEnvironment } from "./Environment.ts";
5
5
 
6
6
  export const of = (endpoint: string) =>
7
7
  Layer.succeed(Endpoint.Endpoint, endpoint);
8
8
 
9
- export const fromStageConfig = () =>
10
- Layer.unwrap(
11
- StageConfig.asEffect().pipe(
12
- Effect.map((config) =>
13
- config.endpoint === undefined ? Layer.empty : of(config.endpoint),
14
- ),
9
+ /**
10
+ * Derive a custom endpoint (if any) from the surrounding
11
+ * {@link AWSEnvironment}. If the environment has no `endpoint` set, this
12
+ * Layer is empty (the SDK uses its default endpoint resolver).
13
+ */
14
+ export const fromEnvironment = Layer.unwrap(
15
+ AWSEnvironment.asEffect().pipe(
16
+ Effect.map((env) =>
17
+ env.endpoint === undefined ? Layer.empty : of(env.endpoint),
15
18
  ),
16
- );
19
+ ),
20
+ );
@@ -0,0 +1,123 @@
1
+ import * as Auth from "@distilled.cloud/aws/Auth";
2
+ import {
3
+ fromAwsCredentialIdentity,
4
+ type CredentialsError,
5
+ type ResolvedCredentials,
6
+ } from "@distilled.cloud/aws/Credentials";
7
+ import type { AwsCredentialIdentity } from "@smithy/types";
8
+ import * as Config from "effect/Config";
9
+ import * as Context from "effect/Context";
10
+ import * as Data from "effect/Data";
11
+ import * as Effect from "effect/Effect";
12
+ import * as Layer from "effect/Layer";
13
+ import * as Option from "effect/Option";
14
+
15
+ export const AWS_PROFILE = Config.string("AWS_PROFILE").pipe(
16
+ Config.withDefault("default"),
17
+ );
18
+
19
+ export const AWS_REGION = Config.string("AWS_REGION");
20
+
21
+ export type AccountID = string;
22
+ export type RegionID = string;
23
+
24
+ export class FailedToGetAccount extends Data.TaggedError(
25
+ "AWS::Environment::FailedToGetAccount",
26
+ )<{
27
+ message: string;
28
+ cause: Error;
29
+ }> {}
30
+
31
+ /**
32
+ * Fully-resolved AWS environment for a stack. Mirrors `CloudflareEnvironment`:
33
+ * one Context.Service that holds account, region, credentials, endpoint, and
34
+ * (optionally) the SSO profile name.
35
+ *
36
+ * `credentials` is held as an Effect so callers can refresh on each access
37
+ * (SSO sessions expire). The Effect itself is constructed once when this
38
+ * service is built; resolving it lazily preserves @distilled.cloud/aws's
39
+ * existing `Credentials` semantics.
40
+ */
41
+ export interface AWSEnvironmentShape {
42
+ accountId: AccountID;
43
+ region: RegionID;
44
+ credentials: Effect.Effect<ResolvedCredentials, CredentialsError>;
45
+ endpoint?: string;
46
+ profile?: string;
47
+ }
48
+
49
+ export class AWSEnvironment extends Context.Service<
50
+ AWSEnvironment,
51
+ AWSEnvironmentShape
52
+ >()("AWS::Environment") {}
53
+
54
+ /**
55
+ * Build an `AWSEnvironment` from an SSO profile (`AWS_PROFILE` env var,
56
+ * defaults to `"default"`). Uses the profile's `sso_account_id` and `region`,
57
+ * and resolves credentials lazily via `aws sso login`.
58
+ */
59
+ export const Default = Layer.effect(
60
+ AWSEnvironment,
61
+ Effect.suspend(() => loadDefault()),
62
+ ).pipe(Layer.orDie);
63
+
64
+ export const loadDefault = () =>
65
+ Effect.gen(function* () {
66
+ const profileName = yield* AWS_PROFILE;
67
+ const auth = yield* Auth.Default;
68
+ const profile = yield* auth.loadProfile(profileName);
69
+ if (!profile.sso_account_id) {
70
+ return yield* Effect.die(
71
+ `AWS SSO profile '${profileName}' is missing sso_account_id`,
72
+ );
73
+ }
74
+ const region =
75
+ profile.region ??
76
+ (yield* AWS_REGION.pipe(
77
+ Config.option,
78
+ Config.map(Option.getOrElse(() => "us-east-1")),
79
+ ));
80
+ return {
81
+ profile: profileName,
82
+ accountId: profile.sso_account_id,
83
+ region,
84
+ credentials: auth.loadProfileCredentials(profileName),
85
+ } satisfies AWSEnvironmentShape;
86
+ });
87
+
88
+ export interface AWSEnvironmentStaticInput {
89
+ accountId: AccountID;
90
+ region: RegionID;
91
+ credentials: AwsCredentialIdentity;
92
+ endpoint?: string;
93
+ profile?: string;
94
+ }
95
+
96
+ const isStatic = (
97
+ shape: AWSEnvironmentShape | AWSEnvironmentStaticInput,
98
+ ): shape is AWSEnvironmentStaticInput =>
99
+ shape.credentials != null &&
100
+ typeof (shape.credentials as AwsCredentialIdentity).accessKeyId === "string";
101
+
102
+ /**
103
+ * Build an `AWSEnvironment` Layer directly from values — useful for
104
+ * static credentials in CI or tests.
105
+ *
106
+ * Named `makeEnvironment` rather than `of` because `Context.Service.of`
107
+ * already exists with different semantics (builds the service value, not
108
+ * a Layer); putting both on `AWSEnvironment` would be confusing.
109
+ */
110
+ export const makeEnvironment = (
111
+ shape: AWSEnvironmentShape | AWSEnvironmentStaticInput,
112
+ ) =>
113
+ Layer.succeed(
114
+ AWSEnvironment,
115
+ isStatic(shape)
116
+ ? {
117
+ ...shape,
118
+ credentials: Effect.succeed(
119
+ fromAwsCredentialIdentity(shape.credentials),
120
+ ),
121
+ }
122
+ : shape,
123
+ );
@@ -13,7 +13,7 @@ import {
13
13
  diffTags,
14
14
  hasAlchemyTags,
15
15
  } from "../../Tags.ts";
16
- import { Account, type AccountID } from "../Account.ts";
16
+ import { AWSEnvironment, type AccountID } from "../Environment.ts";
17
17
  import type { RegionID } from "../Region.ts";
18
18
  import type { QueueArn } from "../SQS/Queue.ts";
19
19
 
@@ -121,7 +121,7 @@ export const EventBusProvider = () =>
121
121
  EventBus,
122
122
  Effect.gen(function* () {
123
123
  const region = yield* Region;
124
- const accountId = yield* Account;
124
+ const { accountId } = yield* AWSEnvironment;
125
125
 
126
126
  const createEventBusName = (id: string, props: { name?: string } = {}) =>
127
127
  Effect.gen(function* () {
@@ -4,7 +4,7 @@ import * as Effect from "effect/Effect";
4
4
  import * as Layer from "effect/Layer";
5
5
  import * as Binding from "../../Binding.ts";
6
6
  import * as Output from "../../Output.ts";
7
- import { Account } from "../Account.ts";
7
+ import { AWSEnvironment } from "../Environment.ts";
8
8
  import { isFunction } from "../Lambda/Function.ts";
9
9
  import type { EventBus } from "./EventBus.ts";
10
10
 
@@ -58,7 +58,7 @@ export class ListRulesPolicy extends Binding.Policy<
58
58
  export const ListRulesPolicyLive = ListRulesPolicy.layer.effect(
59
59
  Effect.gen(function* () {
60
60
  const region = yield* Region;
61
- const accountId = yield* Account;
61
+ const { accountId } = yield* AWSEnvironment;
62
62
 
63
63
  return Effect.fn(function* (host, bus?: EventBus) {
64
64
  if (isFunction(host)) {
@@ -3,7 +3,7 @@ import * as eventbridge from "@distilled.cloud/aws/eventbridge";
3
3
  import * as Effect from "effect/Effect";
4
4
  import * as Layer from "effect/Layer";
5
5
  import * as Binding from "../../Binding.ts";
6
- import { Account } from "../Account.ts";
6
+ import { AWSEnvironment } from "../Environment.ts";
7
7
  import { isFunction } from "../Lambda/Function.ts";
8
8
  import type { EventBus } from "./EventBus.ts";
9
9
 
@@ -62,7 +62,7 @@ export class PutEventsPolicy extends Binding.Policy<
62
62
  export const PutEventsPolicyLive = PutEventsPolicy.layer.effect(
63
63
  Effect.gen(function* () {
64
64
  const region = yield* Region;
65
- const accountId = yield* Account;
65
+ const { accountId } = yield* AWSEnvironment;
66
66
 
67
67
  return Effect.fn(function* (host, bus?: EventBus) {
68
68
  if (isFunction(host)) {
@@ -13,7 +13,7 @@ import {
13
13
  diffTags,
14
14
  hasAlchemyTags,
15
15
  } from "../../Tags.ts";
16
- import { Account, type AccountID } from "../Account.ts";
16
+ import { AWSEnvironment, type AccountID } from "../Environment.ts";
17
17
  import type { RegionID } from "../Region.ts";
18
18
 
19
19
  export type {
@@ -273,7 +273,7 @@ export const RuleProvider = () =>
273
273
  Rule,
274
274
  Effect.gen(function* () {
275
275
  const region = yield* Region;
276
- const accountId = yield* Account;
276
+ const { accountId } = yield* AWSEnvironment;
277
277
 
278
278
  const createRuleName = (id: string, props: { name?: string } = {}) => {
279
279
  if (props.name) {
@@ -5,7 +5,7 @@ import * as Provider from "../../Provider.ts";
5
5
  import { Resource } from "../../Resource.ts";
6
6
  import type { Providers } from "../Providers.ts";
7
7
  import { diffTags } from "../../Tags.ts";
8
- import { Account } from "../Account.ts";
8
+ import { AWSEnvironment } from "../Environment.ts";
9
9
  import { toTagRecord } from "./common.ts";
10
10
 
11
11
  export interface OpenIDConnectProviderProps {
@@ -65,7 +65,7 @@ export const OpenIDConnectProviderProvider = () =>
65
65
  Provider.effect(
66
66
  OpenIDConnectProvider,
67
67
  Effect.gen(function* () {
68
- const accountId = yield* Account;
68
+ const { accountId } = yield* AWSEnvironment;
69
69
  const oidcArnFromUrl = (url: string) =>
70
70
  `arn:aws:iam::${accountId}:oidc-provider/${url.replace(/^https?:\/\//, "")}`;
71
71
 
@@ -11,8 +11,8 @@ import {
11
11
  diffTags,
12
12
  hasTags,
13
13
  } from "../../Tags.ts";
14
- import type { AccountID } from "../Account.ts";
15
- import { Account } from "../Account.ts";
14
+ import type { AccountID } from "../Environment.ts";
15
+ import { AWSEnvironment } from "../Environment.ts";
16
16
  import {
17
17
  oldestNondefaultPolicyVersion,
18
18
  parsePolicyDocument,
@@ -113,7 +113,7 @@ export const PolicyProvider = () =>
113
113
  Provider.effect(
114
114
  Policy,
115
115
  Effect.gen(function* () {
116
- const accountId = yield* Account;
116
+ const { accountId } = yield* AWSEnvironment;
117
117
 
118
118
  const toPolicyName = (id: string, props: PolicyProps) =>
119
119
  props.policyName
@@ -11,8 +11,8 @@ import {
11
11
  diffTags,
12
12
  hasTags,
13
13
  } from "../../Tags.ts";
14
- import type { AccountID } from "../Account.ts";
15
- import { Account } from "../Account.ts";
14
+ import type { AccountID } from "../Environment.ts";
15
+ import { AWSEnvironment } from "../Environment.ts";
16
16
  import type { PolicyDocument } from "./Policy.ts";
17
17
  import {
18
18
  parsePolicyDocument,
@@ -107,7 +107,7 @@ export const RoleProvider = () =>
107
107
  Provider.effect(
108
108
  Role,
109
109
  Effect.gen(function* () {
110
- yield* Account;
110
+ yield* AWSEnvironment;
111
111
 
112
112
  const toRoleName = (id: string, props: { roleName?: string } = {}) =>
113
113
  props.roleName
@@ -337,7 +337,7 @@ export const RoleProvider = () =>
337
337
  });
338
338
 
339
339
  const roleArn = (created.Role?.Arn ??
340
- `arn:aws:iam::${yield* Account}:role/${roleName}`) as RoleArn;
340
+ `arn:aws:iam::${(yield* AWSEnvironment).accountId}:role/${roleName}`) as RoleArn;
341
341
  yield* session.note(roleArn);
342
342
 
343
343
  return {
@@ -17,7 +17,7 @@ import {
17
17
  hasAlchemyTags,
18
18
  type Tags,
19
19
  } from "../../Tags.ts";
20
- import { Account, type AccountID } from "../Account.ts";
20
+ import { AWSEnvironment, type AccountID } from "../Environment.ts";
21
21
  import type { RegionID } from "../Region.ts";
22
22
 
23
23
  export type StreamRecord = lambda.KinesisStreamRecord;
@@ -445,7 +445,7 @@ export const StreamProvider = () =>
445
445
  Stream,
446
446
  Effect.gen(function* () {
447
447
  const region = yield* Region;
448
- const accountId = yield* Account;
448
+ const { accountId } = yield* AWSEnvironment;
449
449
 
450
450
  return {
451
451
  stables: ["streamName", "streamArn"],
@@ -9,7 +9,7 @@ import * as Provider from "../../Provider.ts";
9
9
  import { Resource } from "../../Resource.ts";
10
10
  import type { Providers } from "../Providers.ts";
11
11
  import { createInternalTags, diffTags, hasTags } from "../../Tags.ts";
12
- import { Account } from "../Account.ts";
12
+ import { AWSEnvironment } from "../Environment.ts";
13
13
 
14
14
  export type StartingPosition = "TRIM_HORIZON" | "LATEST" | "AT_TIMESTAMP";
15
15
 
@@ -180,7 +180,7 @@ export const EventSourceMappingProvider = () =>
180
180
  EventSourceMapping,
181
181
  Effect.gen(function* () {
182
182
  const region = yield* Region;
183
- const accountId = yield* Account;
183
+ const { accountId } = yield* AWSEnvironment;
184
184
 
185
185
  const createEventSourceMappingTags = Effect.fn(function* (id: string) {
186
186
  const internalTags = yield* createInternalTags(id);
@@ -29,7 +29,7 @@ import { Stack } from "../../Stack.ts";
29
29
  import { createInternalTags, createTagsList, hasTags } from "../../Tags.ts";
30
30
  import { sha256 } from "../../Util/sha256.ts";
31
31
  import { zipCode } from "../../Util/zip.ts";
32
- import { Account } from "../Account.ts";
32
+ import { AWSEnvironment } from "../Environment.ts";
33
33
  import { Assets } from "../Assets.ts";
34
34
  import * as IAM from "../IAM/index.ts";
35
35
  import type { PolicyStatement } from "../IAM/Policy.ts";
@@ -428,7 +428,7 @@ export const FunctionProvider = () =>
428
428
  Function,
429
429
  Effect.gen(function* () {
430
430
  const stack = yield* Stack;
431
- const accountId = yield* Account;
431
+ const { accountId } = yield* AWSEnvironment;
432
432
  const region = yield* Region;
433
433
  const fs = yield* FileSystem.FileSystem;
434
434
  const virtualEntryPlugin = yield* Bundle.virtualEntryPlugin;
@@ -90,7 +90,7 @@ export interface Permission extends Resource<
90
90
  * functionName: yield* fn.functionArn(),
91
91
  * principal: "s3.amazonaws.com",
92
92
  * sourceArn: yield* bucket.bucketArn,
93
- * sourceAccount: yield* Account,
93
+ * sourceAccount: (yield* AWSEnvironment).accountId,
94
94
  * });
95
95
  * ```
96
96
  *
@@ -7,8 +7,8 @@ import * as Provider from "../../Provider.ts";
7
7
  import { Resource } from "../../Resource.ts";
8
8
  import type { Providers } from "../Providers.ts";
9
9
  import { createInternalTags, diffTags } from "../../Tags.ts";
10
- import type { AccountID } from "../Account.ts";
11
- import { Account } from "../Account.ts";
10
+ import type { AccountID } from "../Environment.ts";
11
+ import { AWSEnvironment } from "../Environment.ts";
12
12
  import type { RegionID } from "../Region.ts";
13
13
 
14
14
  export type LogGroupName = string;
@@ -66,7 +66,7 @@ export const LogGroupProvider = () =>
66
66
  LogGroup,
67
67
  Effect.gen(function* () {
68
68
  const region = yield* Region;
69
- const accountId = yield* Account;
69
+ const { accountId } = yield* AWSEnvironment;
70
70
 
71
71
  const toLogGroupName = (
72
72
  id: string,
@@ -2,9 +2,9 @@ import * as Layer from "effect/Layer";
2
2
  import { Command, CommandProvider } from "../Build/Command.ts";
3
3
  import * as Provider from "../Provider.ts";
4
4
  import { Random, RandomProvider } from "../Random.ts";
5
- import * as Account from "./Account.ts";
6
5
  import * as ACM from "./ACM/index.ts";
7
6
  import * as Assets from "./Assets.ts";
7
+ import { AwsAuth } from "./AuthProvider.ts";
8
8
  import * as AutoScaling from "./AutoScaling/index.ts";
9
9
  import * as CloudFront from "./CloudFront/index.ts";
10
10
  import * as CloudWatch from "./CloudWatch/index.ts";
@@ -32,7 +32,7 @@ import * as Scheduler from "./Scheduler/index.ts";
32
32
  import * as SecretsManager from "./SecretsManager/index.ts";
33
33
  import * as SNS from "./SNS/index.ts";
34
34
  import * as SQS from "./SQS/index.ts";
35
- import { DefaultStageConfig } from "./StageConfig.ts";
35
+ import { Default as DefaultEnvironment } from "./Environment.ts";
36
36
  import * as Website from "./Website/index.ts";
37
37
 
38
38
  export class Providers extends Provider.ProviderCollection<Providers>()(
@@ -516,10 +516,10 @@ export const providers = () =>
516
516
  Assets.AssetsProvider(),
517
517
  ),
518
518
  ),
519
- Layer.provideMerge(Account.fromStageConfig()),
520
- Layer.provideMerge(Region.fromStageConfig()),
521
- Layer.provideMerge(Credentials.fromStageConfig()),
522
- Layer.provideMerge(Endpoint.fromStageConfig()),
523
- Layer.provideMerge(DefaultStageConfig),
519
+ Layer.provideMerge(Region.fromEnvironment),
520
+ Layer.provideMerge(Credentials.fromEnvironment),
521
+ Layer.provideMerge(Endpoint.fromEnvironment),
522
+ Layer.provideMerge(DefaultEnvironment),
523
+ Layer.provideMerge(AwsAuth),
524
524
  Layer.orDie,
525
525
  );
package/src/AWS/Region.ts CHANGED
@@ -1,77 +1,20 @@
1
- import * as Auth from "@distilled.cloud/aws/Auth";
2
1
  import * as Region from "@distilled.cloud/aws/Region";
3
- import * as Config from "effect/Config";
4
- import * as Data from "effect/Data";
5
2
  import * as Effect from "effect/Effect";
6
3
  import * as Layer from "effect/Layer";
7
- import * as Option from "effect/Option";
8
- import { StageConfig } from "./StageConfig.ts";
4
+ import { AWSEnvironment } from "./Environment.ts";
9
5
 
10
6
  export { Region } from "@distilled.cloud/aws/Region";
11
-
12
- export const AWS_REGION = Config.string("AWS_REGION");
13
-
14
- export type RegionID = string;
7
+ export { AWS_REGION, type RegionID } from "./Environment.ts";
15
8
 
16
9
  export const of = (region: string) => Layer.succeed(Region.Region, region);
17
10
 
18
11
  export const fromEnvOrElse = (region: string) =>
19
12
  Layer.succeed(Region.Region, process.env.AWS_REGION ?? region);
20
13
 
21
- export class EnvironmentVariableNotSet extends Data.TaggedError(
22
- "EnvironmentVariableNotSet",
23
- )<{
24
- message: string;
25
- variable: string;
26
- }> {}
27
-
28
- const tryGetAWSRegion = () =>
29
- Config.option(AWS_REGION).pipe(Config.map(Option.getOrUndefined));
30
-
31
- export const fromEnv = () =>
32
- Layer.effect(
33
- Region.Region,
34
- Effect.gen(function* () {
35
- const region = yield* tryGetAWSRegion();
36
- if (!region) {
37
- return yield* Effect.fail(
38
- new EnvironmentVariableNotSet({
39
- message: "AWS_REGION is not set",
40
- variable: "AWS_REGION",
41
- }),
42
- );
43
- }
44
- return region;
45
- }),
46
- );
47
-
48
- export class AWSStageConfigRegionMissing extends Data.TaggedError(
49
- "AWSStageConfigMissing",
50
- )<{
51
- message: string;
52
- stage: string;
53
- }> {}
54
-
55
- export const fromStageConfig = () =>
56
- Layer.effect(
57
- Region.Region,
58
- Effect.gen(function* () {
59
- const config = yield* StageConfig;
60
- const auth = yield* Auth.Default;
61
- if (config.region) {
62
- return config.region;
63
- } else if (config.profile) {
64
- const profile = yield* auth.loadProfile(config.profile);
65
- if (profile.region) {
66
- return profile.region;
67
- }
68
- }
69
- const region = yield* tryGetAWSRegion();
70
- if (region) {
71
- return region;
72
- }
73
- return yield* Effect.die(
74
- "No AWS region found in stage config, SSO profile, or environment variable",
75
- );
76
- }),
77
- );
14
+ /**
15
+ * Derive the AWS region from the surrounding {@link AWSEnvironment}.
16
+ */
17
+ export const fromEnvironment = Layer.effect(
18
+ Region.Region,
19
+ Effect.map(AWSEnvironment.asEffect(), (env) => env.region),
20
+ );
@@ -10,7 +10,7 @@ import * as Provider from "../../Provider.ts";
10
10
  import { Resource, type ResourceBinding } from "../../Resource.ts";
11
11
  import type { Providers } from "../Providers.ts";
12
12
  import { diffTags } from "../../Tags.ts";
13
- import { Account, type AccountID } from "../Account.ts";
13
+ import { AWSEnvironment, type AccountID } from "../Environment.ts";
14
14
  import type { PolicyStatement } from "../IAM/Policy.ts";
15
15
  import type { RegionID } from "../Region.ts";
16
16
 
@@ -257,7 +257,7 @@ export const BucketProvider = () =>
257
257
  news: BucketProps;
258
258
  }) {
259
259
  const region = yield* Region;
260
- const accountId = yield* Account;
260
+ const { accountId } = yield* AWSEnvironment;
261
261
  const bucketName = yield* createBucketName(id, news);
262
262
 
263
263
  yield* Effect.logInfo(
@@ -6,7 +6,7 @@ import * as Provider from "../../Provider.ts";
6
6
  import { Resource } from "../../Resource.ts";
7
7
  import type { Providers } from "../Providers.ts";
8
8
  import { createInternalTags, createTagsList, diffTags } from "../../Tags.ts";
9
- import type { AccountID } from "../Account.ts";
9
+ import type { AccountID } from "../Environment.ts";
10
10
  import type { RegionID } from "../Region.ts";
11
11
 
12
12
  export type TopicName = string;
@@ -6,9 +6,9 @@ import { isResolved } from "../../Diff.ts";
6
6
  import { createPhysicalName } from "../../PhysicalName.ts";
7
7
  import * as Provider from "../../Provider.ts";
8
8
  import { Resource, type ResourceBinding } from "../../Resource.ts";
9
- import type { Providers } from "../Providers.ts";
10
- import { Account, type AccountID } from "../Account.ts";
9
+ import { AWSEnvironment, type AccountID } from "../Environment.ts";
11
10
  import type { PolicyStatement } from "../IAM/Policy.ts";
11
+ import type { Providers } from "../Providers.ts";
12
12
  import type { RegionID } from "../Region.ts";
13
13
 
14
14
  export type QueueName = string;
@@ -160,7 +160,7 @@ export const QueueProvider = () =>
160
160
  Queue,
161
161
  Effect.gen(function* () {
162
162
  const region = yield* Region;
163
- const accountId = yield* Account;
163
+ const { accountId } = yield* AWSEnvironment;
164
164
  const createQueueName = Effect.fnUntraced(function* (
165
165
  id: string,
166
166
  props: {
package/src/AWS/index.ts CHANGED
@@ -1,11 +1,9 @@
1
- export * from "./Account.ts";
2
1
  export * from "./Arn.ts";
3
2
  export * from "./Assets.ts";
4
3
  export * from "./Bootstrap.ts";
5
4
  export * from "./Context.ts";
6
- export * from "./Profile.ts";
5
+ export * from "./Environment.ts";
7
6
  export * from "./Providers.ts";
8
- export * from "./StageConfig.ts";
9
7
 
10
8
  export { Region } from "@distilled.cloud/aws/Region";
11
9