@reventlessdev/reventless-aws 3.0.0-alpha.265 → 3.0.0-alpha.266

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.
@@ -0,0 +1,127 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Aws from "@pulumi/aws";
4
+ import * as IAM$PulumiAws from "@reventlessdev/rescript-pulumi-aws/src/IAM/IAM.res.mjs";
5
+ import * as Output$Pulumi from "@reventlessdev/rescript-pulumi-pulumi/src/Output.res.mjs";
6
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
7
+ import * as Pulumi from "@pulumi/pulumi";
8
+ import * as Lambda$PulumiAws from "@reventlessdev/rescript-pulumi-aws/src/Lambda/Lambda.res.mjs";
9
+ import * as AWS$ReventlessAws from "../AWS.res.mjs";
10
+ import * as AWS_Tags$ReventlessAws from "../AWS_Tags.res.mjs";
11
+ import * as PolicyDocument$PulumiAws from "@reventlessdev/rescript-pulumi-aws/src/IAM/PolicyDocument.res.mjs";
12
+ import * as Util_Bundle$ReventlessAws from "../../util/Util_Bundle.res.mjs";
13
+ import * as Util_Pulumi$ReventlessCore from "@reventlessdev/reventless-core/src/util/Util_Pulumi.res.mjs";
14
+ import * as Util_LambdaLogging$ReventlessAws from "../../util/Util_LambdaLogging.res.mjs";
15
+ import * as AppSync_Resolver_Native$ReventlessAws from "../Api/AppSync_Resolver_Native.res.mjs";
16
+
17
+ let invokeCode = `import { util } from '@aws-appsync/utils';
18
+ export function request(ctx) {
19
+ return { operation: 'Invoke', payload: { arguments: ctx.args } };
20
+ }
21
+ export function response(ctx) {
22
+ if (ctx.error) util.error(ctx.error.message, ctx.error.type);
23
+ return ctx.result;
24
+ }
25
+ `;
26
+
27
+ function make(api, placeIndexName, nameOpt, opts) {
28
+ let name = nameOpt !== undefined ? nameOpt : "GeocodeService";
29
+ let opts$1 = Util_Pulumi$ReventlessCore.ComponentResourceOptions.toCustomResourceOptions(opts);
30
+ let lambdaRole = IAM$PulumiAws.Role.makeWithDefaultPolicy(name + "Lambda", Pulumi.output(AWS$ReventlessAws.Lambda.principal), AWS_Tags$ReventlessAws.make(name + "Lambda", "Platform", "Identity", "Platform", undefined, undefined, undefined, undefined), opts$1);
31
+ placeIndexName.apply(idx => {
32
+ let arn = `arn:aws:geo:*:*:place-index/` + idx;
33
+ new (Aws.iam.RolePolicy)(name + "LambdaPolicy", {
34
+ policy: PolicyDocument$PulumiAws.toJsonString(PolicyDocument$PulumiAws.make(undefined, name + "LambdaPolicy", [
35
+ {
36
+ Sid: "AllowLambdaLogging",
37
+ Effect: "Allow",
38
+ Action: [
39
+ "logs:CreateLogGroup",
40
+ "logs:CreateLogStream",
41
+ "logs:PutLogEvents"
42
+ ],
43
+ Resource: "arn:aws:logs:*:*:*"
44
+ },
45
+ {
46
+ Sid: "AllowGeocode",
47
+ Effect: "Allow",
48
+ Action: "geo:SearchPlaceIndexForText",
49
+ Resource: arn
50
+ }
51
+ ])),
52
+ role: lambdaRole.id
53
+ }, opts$1);
54
+ });
55
+ let packageDirs = Object.fromEntries([[
56
+ "@reventlessdev/reventless-aws",
57
+ Util_Bundle$ReventlessAws.resolvePackageRoot(undefined, "@reventlessdev/reventless-aws")
58
+ ]]);
59
+ let match = Util_Bundle$ReventlessAws.buildCodeArchive("@reventlessdev/reventless-aws/src/adapter/Geocoder/Geocoder_AwsLocation_Resolver_Ops.res.mjs", packageDirs, undefined);
60
+ let layers = Stdlib_Option.getOr(Stdlib_Option.map(Lambda$PulumiAws.reventlessLayerArn, arn => [arn]), []);
61
+ let lambda = new (Aws.lambda.Function)(name + "Lambda", {
62
+ handler: "index.handler",
63
+ runtime: "nodejs22.x",
64
+ code: match.code,
65
+ role: lambdaRole.arn,
66
+ memorySize: 256,
67
+ timeout: 30,
68
+ layers: layers,
69
+ tags: AWS_Tags$ReventlessAws.make(name + "Lambda", "Platform", "Runtime", "Platform", undefined, undefined, undefined, undefined),
70
+ environment: {
71
+ variables: Object.fromEntries([
72
+ [
73
+ "Environment",
74
+ Pulumi.getStack()
75
+ ],
76
+ [
77
+ "PLACE_INDEX_NAME",
78
+ placeIndexName
79
+ ],
80
+ [
81
+ "NODE_OPTIONS",
82
+ Util_Bundle$ReventlessAws.esmLoaderNodeOptions
83
+ ],
84
+ [
85
+ "ESM_FALLBACK_DIRS",
86
+ Util_Bundle$ReventlessAws.esmFallbackDirs
87
+ ],
88
+ Util_LambdaLogging$ReventlessAws.logLevelEntry()
89
+ ])
90
+ },
91
+ sourceCodeHash: match.sourceCodeHash
92
+ }, opts$1);
93
+ Util_LambdaLogging$ReventlessAws.makeManagedLogGroup(name + "Lambda", lambda.name, AWS_Tags$ReventlessAws.make(name + "LambdaLogGroup", "Platform", "Logs", "Platform", undefined, undefined, undefined, undefined), opts$1, undefined);
94
+ let dataSourceRole = IAM$PulumiAws.Role.makeWithDefaultPolicy(name + "DataSource", Pulumi.output(AWS$ReventlessAws.AppSync.principal), AWS_Tags$ReventlessAws.make(name + "DataSource", "Platform", "Identity", "Platform", undefined, undefined, undefined, undefined), opts$1);
95
+ Pulumi.all([
96
+ lambda.arn,
97
+ dataSourceRole.id
98
+ ]).apply(param => {
99
+ new (Aws.iam.RolePolicy)(name + "DataSource", {
100
+ policy: PolicyDocument$PulumiAws.toJsonString(PolicyDocument$PulumiAws.make(undefined, name + "DataSourcePolicy", [{
101
+ Sid: "AllowDataSourceInvokeLambda",
102
+ Effect: "Allow",
103
+ Action: "lambda:InvokeFunction",
104
+ Resource: param[0]
105
+ }])),
106
+ role: param[1]
107
+ }, opts$1);
108
+ });
109
+ let dataSource = new (Aws.appsync.DataSource)(name + "DataSource", {
110
+ type: "AWS_LAMBDA",
111
+ apiId: Output$Pulumi.flatMap(api, api => api.id),
112
+ lambdaConfig: {
113
+ functionArn: lambda.arn
114
+ },
115
+ serviceRoleArn: dataSourceRole.arn
116
+ }, opts$1);
117
+ AppSync_Resolver_Native$ReventlessAws.makeUnitJsResolver(name + "Geocode", api, dataSource.name, "Query", "geocode", invokeCode, opts$1);
118
+ return {
119
+ resources: [lambda.arn]
120
+ };
121
+ }
122
+
123
+ export {
124
+ invokeCode,
125
+ make,
126
+ }
127
+ /* @pulumi/aws Not a pure module */
@@ -0,0 +1,55 @@
1
+ // Runtime handler for the geocoder's client door — compiled, type-checked, and
2
+ // Pulumi-free so it can be shipped as an EntryPoint module
3
+ // (`Geocoder_AwsLocation_Resolver` bundles it and attaches it as the platform API's
4
+ // `Query.geocode` Lambda data source). Keeping it out of the deploy-time module
5
+ // avoids both the serialized-closure SDK skew and a deploy-time Pulumi import
6
+ // leaking into the Lambda's cold-start graph.
7
+ //
8
+ // Invoked by an AppSync resolver, not a Function URL: the platform API's Cognito
9
+ // authorizer has already authenticated the caller, so there is no token to decode
10
+ // and no anonymous surface. The SDK call, the `[lng, lat]` order and the relevance
11
+ // handling all live in `Geocoder_AwsLocation_Backend`, shared with the unattended
12
+ // slice path so one module owns the AWS Location call.
13
+ //
14
+ // Returns the ranked candidates as `[{label, lat, lng, relevance?}]`. A no-match is
15
+ // an empty array — a browser search box degrades to "no results". A service failure
16
+ // throws, which the resolver's response mapper turns into a GraphQL error rather
17
+ // than an empty answer: the client half of D2's status contract, so a browser can
18
+ // tell "no such address" from "the geocoder is down" the way the Function URL's
19
+ // `200`/`502` split did.
20
+
21
+ let candidateJson = (c: Reventless.Geocoding.candidate): JSON.t =>
22
+ Dict.fromArray(
23
+ Array.concat(
24
+ [
25
+ ("label", JSON.Encode.string(c.label)),
26
+ ("lat", JSON.Encode.float(c.point.lat)),
27
+ ("lng", JSON.Encode.float(c.point.lng)),
28
+ ],
29
+ switch c.relevance {
30
+ | Some(rel) => [("relevance", JSON.Encode.float(rel))]
31
+ | None => []
32
+ },
33
+ ),
34
+ )->JSON.Encode.object
35
+
36
+ // Only `text` is read; `ctx.identity` is forwarded by the resolver but the geocoder
37
+ // does not scope by caller, so the handler ignores it.
38
+ type geocodeArgs = {text?: string}
39
+ type appSyncEvent = {arguments?: geocodeArgs}
40
+
41
+ let handler = async (event: appSyncEvent): array<JSON.t> => {
42
+ let indexName = switch NodeProcess.env->Dict.get("PLACE_INDEX_NAME") {
43
+ | Some("") | None => ""
44
+ | Some(v) => v
45
+ }
46
+ let text = event.arguments->Option.flatMap(a => a.text)->Option.getOr("")
47
+ switch await Geocoder_AwsLocation_Backend.search(~indexName, ~text) {
48
+ | Ok(candidates) => candidates->Array.map(candidateJson)
49
+ // The provider answered and had nothing — a true, final empty answer.
50
+ | Error(NoMatch) => []
51
+ // Misconfigured (no index) or the service failed: throw so `ctx.error` is set and
52
+ // the caller sees an error, never a silent empty list it would read as "no match".
53
+ | Error(Unavailable(msg)) => JsError.throwWithMessage(`geocoder unavailable: ${msg}`)
54
+ }
55
+ }
@@ -0,0 +1,48 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
4
+ import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
5
+ import * as Geocoder_AwsLocation_Backend$ReventlessAws from "./Geocoder_AwsLocation_Backend.res.mjs";
6
+
7
+ function candidateJson(c) {
8
+ let rel = c.relevance;
9
+ return Object.fromEntries([
10
+ [
11
+ "label",
12
+ c.label
13
+ ],
14
+ [
15
+ "lat",
16
+ c.point.lat
17
+ ],
18
+ [
19
+ "lng",
20
+ c.point.lng
21
+ ]
22
+ ].concat(rel !== undefined ? [[
23
+ "relevance",
24
+ rel
25
+ ]] : []));
26
+ }
27
+
28
+ async function handler(event) {
29
+ let v = process.env["PLACE_INDEX_NAME"];
30
+ let indexName = v !== undefined && v !== "" ? v : "";
31
+ let text = Stdlib_Option.getOr(Stdlib_Option.flatMap(event.arguments, a => a.text), "");
32
+ let candidates = await Geocoder_AwsLocation_Backend$ReventlessAws.search(indexName, text, undefined);
33
+ if (candidates.TAG === "Ok") {
34
+ return candidates._0.map(candidateJson);
35
+ }
36
+ let msg = candidates._0;
37
+ if (typeof msg !== "object") {
38
+ return [];
39
+ } else {
40
+ return Stdlib_JsError.throwWithMessage(`geocoder unavailable: ` + msg._0);
41
+ }
42
+ }
43
+
44
+ export {
45
+ candidateJson,
46
+ handler,
47
+ }
48
+ /* Geocoder_AwsLocation_Backend-ReventlessAws Not a pure module */
@@ -0,0 +1,53 @@
1
+ // Guards the geocode resolver handler's contract — the client door of the
2
+ // geocoding capability (D9 half 2), which replaced the Function URL. The Function
3
+ // URL served two callers through one `200`/`502` body-vs-status split; this handler
4
+ // serves only the browser, through GraphQL, so the contract is simpler:
5
+ //
6
+ // a value returned — an answer (a possibly-empty candidate list)
7
+ // a thrown error — no answer (the resolver's response mapper turns it into a
8
+ // GraphQL error, so the client degrades rather than reading
9
+ // an empty list as "no such address")
10
+ //
11
+ // The two arms below are the ones reachable without a live AWS Location call: an
12
+ // unset index throws (misconfiguration is not a verdict on the address), and an
13
+ // empty query returns `[]` (nothing was asked). The success path and the thrown
14
+ // service-failure path both need the SDK and stay unasserted here — see the plan's
15
+ // Verification note.
16
+
17
+ open JestGlobals
18
+
19
+ let setIndex = v => NodeProcess.env->Dict.set("PLACE_INDEX_NAME", v)
20
+ let clearIndex = () => NodeProcess.env->Dict.delete("PLACE_INDEX_NAME")
21
+
22
+ describe("Geocoder_AwsLocation_Resolver_Ops.handler contract", () => {
23
+ test("an unset PLACE_INDEX_NAME throws — a misconfiguration, not a verdict", async () => {
24
+ clearIndex()
25
+ let threw = switch await Geocoder_AwsLocation_Resolver_Ops.handler({
26
+ arguments: {text: "10 Downing Street"},
27
+ }) {
28
+ | _ => false
29
+ | exception _ => true
30
+ }
31
+ // Returning `[]` here would tell the browser this address does not exist, when
32
+ // in fact the deployment has no geocoder — the client must see an error and be
33
+ // able to distinguish the two, which is the whole point of throwing.
34
+ expect(threw)->toBe(true)
35
+ clearIndex()
36
+ })
37
+
38
+ test("an empty query is an answer — nothing was asked, so `[]`", async () => {
39
+ setIndex("some-index")
40
+ let results = await Geocoder_AwsLocation_Resolver_Ops.handler({arguments: {text: ""}})
41
+ // The empty text short-circuits in the shared backend before any SDK call, so
42
+ // this arm is reachable in a unit test and returns a true, final empty answer.
43
+ expect(results->Array.length)->toBe(0)
44
+ clearIndex()
45
+ })
46
+
47
+ test("a missing text argument is treated as an empty query", async () => {
48
+ setIndex("some-index")
49
+ let results = await Geocoder_AwsLocation_Resolver_Ops.handler({arguments: {}})
50
+ expect(results->Array.length)->toBe(0)
51
+ clearIndex()
52
+ })
53
+ })
@@ -0,0 +1,55 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
4
+ import * as Geocoder_AwsLocation_Resolver_Ops$ReventlessAws from "../src/adapter/Geocoder/Geocoder_AwsLocation_Resolver_Ops.res.mjs";
5
+
6
+ function setIndex(v) {
7
+ process.env["PLACE_INDEX_NAME"] = v;
8
+ }
9
+
10
+ function clearIndex() {
11
+ Stdlib_Dict.$$delete(process.env, "PLACE_INDEX_NAME");
12
+ }
13
+
14
+ globalThis.describe("Geocoder_AwsLocation_Resolver_Ops.handler contract", () => {
15
+ globalThis.test("an unset PLACE_INDEX_NAME throws — a misconfiguration, not a verdict", async () => {
16
+ Stdlib_Dict.$$delete(process.env, "PLACE_INDEX_NAME");
17
+ let threw;
18
+ try {
19
+ await Geocoder_AwsLocation_Resolver_Ops$ReventlessAws.handler({
20
+ arguments: {
21
+ text: "10 Downing Street"
22
+ }
23
+ });
24
+ threw = false;
25
+ } catch (exn) {
26
+ threw = true;
27
+ }
28
+ globalThis.expect(threw).toBe(true);
29
+ return Stdlib_Dict.$$delete(process.env, "PLACE_INDEX_NAME");
30
+ });
31
+ globalThis.test("an empty query is an answer — nothing was asked, so `[]`", async () => {
32
+ setIndex("some-index");
33
+ let results = await Geocoder_AwsLocation_Resolver_Ops$ReventlessAws.handler({
34
+ arguments: {
35
+ text: ""
36
+ }
37
+ });
38
+ globalThis.expect(results.length).toBe(0);
39
+ return Stdlib_Dict.$$delete(process.env, "PLACE_INDEX_NAME");
40
+ });
41
+ globalThis.test("a missing text argument is treated as an empty query", async () => {
42
+ setIndex("some-index");
43
+ let results = await Geocoder_AwsLocation_Resolver_Ops$ReventlessAws.handler({
44
+ arguments: {}
45
+ });
46
+ globalThis.expect(results.length).toBe(0);
47
+ return Stdlib_Dict.$$delete(process.env, "PLACE_INDEX_NAME");
48
+ });
49
+ });
50
+
51
+ export {
52
+ setIndex,
53
+ clearIndex,
54
+ }
55
+ /* Not a pure module */
@@ -1,166 +0,0 @@
1
- // AWS Location Service geocoder behind a public Lambda Function URL.
2
- //
3
- // Deploy-time only: `make` provisions a compiled-EntryPoint Lambda (a plain
4
- // `Lambda.Function` whose code archive re-exports `handler` from the compiled,
5
- // type-checked runtime module `Geocoder_AwsLocation_Ops` and ships the shared
6
- // ESM resolve-hook loader), an IAM execution role scoped to CloudWatch Logs +
7
- // `geo:SearchPlaceIndexForText` on the target place index, and a Function URL
8
- // (no auth) so a browser can geocode directly.
9
- //
10
- // Why an EntryPoint and not a Pulumi `CallbackFunction`: a serialized closure
11
- // bakes the deploy machine's version-specific AWS SDK internals into the archive
12
- // but then resolves `@smithy/*`/`@aws-sdk/*` transitives from independently-
13
- // versioned layer/runtime sources that can disagree at cold start (the exact
14
- // skew that crashed the upload presign service). Shipping the compiled `_Ops`
15
- // module with bare `@aws-sdk/*` imports, resolved through the resolve-hook, loads
16
- // one internally consistent SDK. The runtime logic lives in
17
- // [Geocoder_AwsLocation_Ops.res].
18
-
19
- open PulumiAws
20
-
21
- type serviceOutputs = {
22
- url: Pulumi.Output.t<string>,
23
- resources: array<Pulumi.Output.t<string>>,
24
- }
25
-
26
- let make = (
27
- ~placeIndexName: Pulumi.Input.t<string>,
28
- ~corsOrigins: array<string>=["*"],
29
- ~opts=?,
30
- ): serviceOutputs => {
31
- let serviceName = "GeocoderService"
32
- let opts =
33
- opts->Option.map(ReventlessCore.Util.Pulumi.ComponentResourceOptions.toCustomResourceOptions)
34
-
35
- let lambdaRole = IAM.Role.makeWithDefaultPolicy(
36
- ~name=serviceName,
37
- ~servicePrincipal=AWS.Lambda.principal->Pulumi.Output.make,
38
- ~tags=AWS.Tags.make(
39
- ~name=serviceName,
40
- ~kind=ReventlessCore.ComponentType.Platform,
41
- ~role=Identity,
42
- ~scope=Platform,
43
- ),
44
- ~opts?,
45
- )
46
-
47
- // CloudWatch Logs (so failures are observable) plus least-privilege
48
- // `geo:SearchPlaceIndexForText` on the one place index.
49
- let _policy =
50
- placeIndexName
51
- ->Pulumi.Output.fromInput
52
- ->Pulumi.Output.apply(idx => {
53
- let arn = `arn:aws:geo:*:*:place-index/${idx}`
54
- let _ = IAM.RolePolicy.make(
55
- ~name=`${serviceName}Policy`,
56
- ~args={
57
- policy: PolicyDocument.make(
58
- ~id=`${serviceName}Policy`,
59
- ~statements=[
60
- {
61
- sid: "AllowLambdaLogging",
62
- effect: Allow,
63
- actions: Actions(["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"]),
64
- resources: Resource("arn:aws:logs:*:*:*"),
65
- },
66
- {
67
- sid: "AllowGeocode",
68
- effect: Allow,
69
- actions: Action("geo:SearchPlaceIndexForText"),
70
- resources: Resource(arn),
71
- },
72
- ],
73
- )
74
- ->PolicyDocument.toJsonString
75
- ->Pulumi.Input.make,
76
- role: lambdaRole.id->Pulumi.Output.asInput,
77
- },
78
- ~opts?,
79
- )
80
- })
81
-
82
- // Bundle reventless-aws (the compiled `_Ops` handler lives inside it) and
83
- // re-export its `handler`; buildCodeArchive also ships the ESM resolve-hook.
84
- let packageDirs = Dict.fromArray([
85
- (
86
- "@reventlessdev/reventless-aws",
87
- Util_Bundle.resolvePackageRoot("@reventlessdev/reventless-aws"),
88
- ),
89
- ])
90
- let {code, sourceCodeHash} = Util_Bundle.buildCodeArchive(
91
- ~entryPointModule="@reventlessdev/reventless-aws/src/adapter/Geocoder/Geocoder_AwsLocation_Ops.res.mjs",
92
- ~packageDirs,
93
- )
94
-
95
- let layers =
96
- Lambda.reventlessLayerArn
97
- ->Option.map(arn => [arn->Pulumi.Input.make])
98
- ->Option.getOr([])
99
- ->Pulumi.Input.make
100
-
101
- let lambda = Lambda.Function.make(
102
- ~name=serviceName,
103
- ~args={
104
- handler: "index.handler"->Pulumi.Input.make,
105
- runtime: "nodejs22.x"->Pulumi.Input.make,
106
- code: code->Pulumi.Input.make,
107
- sourceCodeHash: sourceCodeHash->Pulumi.Input.make,
108
- role: lambdaRole.arn->Pulumi.Output.asInput,
109
- memorySize: 256->Pulumi.Input.make,
110
- timeout: 30->Pulumi.Input.make,
111
- layers,
112
- tags: AWS.Tags.make(
113
- ~name=serviceName,
114
- ~kind=ReventlessCore.ComponentType.Platform,
115
- ~role=Runtime,
116
- ~scope=Platform,
117
- ),
118
- environment: (
119
- {
120
- Lambda.Function.variables: Dict.fromArray([
121
- ("Environment", Pulumi.Pulumi.getStackName()->Pulumi.Input.make),
122
- ("PLACE_INDEX_NAME", placeIndexName),
123
- ("NODE_OPTIONS", Util_Bundle.esmLoaderNodeOptions->Pulumi.Input.make),
124
- ("ESM_FALLBACK_DIRS", Util_Bundle.esmFallbackDirs->Pulumi.Input.make),
125
- Util_LambdaLogging.logLevelEntry(),
126
- ]),
127
- }: Lambda.Function.functionEnvironment
128
- )->Pulumi.Input.make,
129
- },
130
- ~opts?,
131
- )
132
-
133
- Util_LambdaLogging.makeManagedLogGroup(
134
- ~name=serviceName,
135
- ~lambdaName=lambda.name,
136
- ~tags=AWS.Tags.make(
137
- ~name=serviceName ++ "LogGroup",
138
- ~kind=ReventlessCore.ComponentType.Platform,
139
- ~role=Logs,
140
- ~scope=Platform,
141
- ),
142
- ~opts?,
143
- (),
144
- )
145
-
146
- let functionUrl = FunctionUrl.make(
147
- ~name=`${serviceName}Url`,
148
- ~args={
149
- authorizationType: FunctionUrl.None,
150
- functionName: lambda.name->Pulumi.Output.asInput,
151
- cors: (
152
- {
153
- allowMethods: ["GET"]->Array.map(Pulumi.Input.make)->Pulumi.Input.make,
154
- allowOrigins: corsOrigins->Array.map(Pulumi.Input.make)->Pulumi.Input.make,
155
- allowHeaders: ["*"]->Array.map(Pulumi.Input.make)->Pulumi.Input.make,
156
- }: FunctionUrl.cors
157
- )->Pulumi.Input.make,
158
- },
159
- ~opts?,
160
- )
161
-
162
- {
163
- url: functionUrl.functionUrl,
164
- resources: [lambda.arn, functionUrl.functionArn],
165
- }
166
- }
@@ -1,105 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as Aws from "@pulumi/aws";
4
- import * as IAM$PulumiAws from "@reventlessdev/rescript-pulumi-aws/src/IAM/IAM.res.mjs";
5
- import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
6
- import * as Pulumi from "@pulumi/pulumi";
7
- import * as Lambda$PulumiAws from "@reventlessdev/rescript-pulumi-aws/src/Lambda/Lambda.res.mjs";
8
- import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
9
- import * as AWS$ReventlessAws from "../AWS.res.mjs";
10
- import * as AWS_Tags$ReventlessAws from "../AWS_Tags.res.mjs";
11
- import * as PolicyDocument$PulumiAws from "@reventlessdev/rescript-pulumi-aws/src/IAM/PolicyDocument.res.mjs";
12
- import * as Util_Bundle$ReventlessAws from "../../util/Util_Bundle.res.mjs";
13
- import * as Util_Pulumi$ReventlessCore from "@reventlessdev/reventless-core/src/util/Util_Pulumi.res.mjs";
14
- import * as Util_LambdaLogging$ReventlessAws from "../../util/Util_LambdaLogging.res.mjs";
15
-
16
- function make(placeIndexName, corsOriginsOpt, opts) {
17
- let corsOrigins = corsOriginsOpt !== undefined ? corsOriginsOpt : ["*"];
18
- let serviceName = "GeocoderService";
19
- let opts$1 = Stdlib_Option.map(opts, Util_Pulumi$ReventlessCore.ComponentResourceOptions.toCustomResourceOptions);
20
- let lambdaRole = IAM$PulumiAws.Role.makeWithDefaultPolicy(serviceName, Pulumi.output(AWS$ReventlessAws.Lambda.principal), AWS_Tags$ReventlessAws.make(serviceName, "Platform", "Identity", "Platform", undefined, undefined, undefined, undefined), opts$1);
21
- placeIndexName.apply(idx => {
22
- let arn = `arn:aws:geo:*:*:place-index/` + idx;
23
- new (Aws.iam.RolePolicy)(serviceName + `Policy`, {
24
- policy: PolicyDocument$PulumiAws.toJsonString(PolicyDocument$PulumiAws.make(undefined, serviceName + `Policy`, [
25
- {
26
- Sid: "AllowLambdaLogging",
27
- Effect: "Allow",
28
- Action: [
29
- "logs:CreateLogGroup",
30
- "logs:CreateLogStream",
31
- "logs:PutLogEvents"
32
- ],
33
- Resource: "arn:aws:logs:*:*:*"
34
- },
35
- {
36
- Sid: "AllowGeocode",
37
- Effect: "Allow",
38
- Action: "geo:SearchPlaceIndexForText",
39
- Resource: arn
40
- }
41
- ])),
42
- role: lambdaRole.id
43
- }, opts$1 !== undefined ? Primitive_option.valFromOption(opts$1) : undefined);
44
- });
45
- let packageDirs = Object.fromEntries([[
46
- "@reventlessdev/reventless-aws",
47
- Util_Bundle$ReventlessAws.resolvePackageRoot(undefined, "@reventlessdev/reventless-aws")
48
- ]]);
49
- let match = Util_Bundle$ReventlessAws.buildCodeArchive("@reventlessdev/reventless-aws/src/adapter/Geocoder/Geocoder_AwsLocation_Ops.res.mjs", packageDirs, undefined);
50
- let layers = Stdlib_Option.getOr(Stdlib_Option.map(Lambda$PulumiAws.reventlessLayerArn, arn => [arn]), []);
51
- let lambda = new (Aws.lambda.Function)(serviceName, {
52
- handler: "index.handler",
53
- runtime: "nodejs22.x",
54
- code: match.code,
55
- role: lambdaRole.arn,
56
- memorySize: 256,
57
- timeout: 30,
58
- layers: layers,
59
- tags: AWS_Tags$ReventlessAws.make(serviceName, "Platform", "Runtime", "Platform", undefined, undefined, undefined, undefined),
60
- environment: {
61
- variables: Object.fromEntries([
62
- [
63
- "Environment",
64
- Pulumi.getStack()
65
- ],
66
- [
67
- "PLACE_INDEX_NAME",
68
- placeIndexName
69
- ],
70
- [
71
- "NODE_OPTIONS",
72
- Util_Bundle$ReventlessAws.esmLoaderNodeOptions
73
- ],
74
- [
75
- "ESM_FALLBACK_DIRS",
76
- Util_Bundle$ReventlessAws.esmFallbackDirs
77
- ],
78
- Util_LambdaLogging$ReventlessAws.logLevelEntry()
79
- ])
80
- },
81
- sourceCodeHash: match.sourceCodeHash
82
- }, opts$1 !== undefined ? Primitive_option.valFromOption(opts$1) : undefined);
83
- Util_LambdaLogging$ReventlessAws.makeManagedLogGroup(serviceName, lambda.name, AWS_Tags$ReventlessAws.make(serviceName + "LogGroup", "Platform", "Logs", "Platform", undefined, undefined, undefined, undefined), opts$1, undefined);
84
- let functionUrl = new (Aws.lambda.FunctionUrl)(serviceName + `Url`, {
85
- authorizationType: "NONE",
86
- functionName: lambda.name,
87
- cors: {
88
- allowHeaders: ["*"].map(prim => prim),
89
- allowMethods: ["GET"].map(prim => prim),
90
- allowOrigins: corsOrigins.map(prim => prim)
91
- }
92
- }, opts$1 !== undefined ? Primitive_option.valFromOption(opts$1) : undefined);
93
- return {
94
- url: functionUrl.functionUrl,
95
- resources: [
96
- lambda.arn,
97
- functionUrl.functionArn
98
- ]
99
- };
100
- }
101
-
102
- export {
103
- make,
104
- }
105
- /* @pulumi/aws Not a pure module */