Skip to content

Commit b522785

Browse files
committed
FEAT: Forward sortation areas with OpenSearch
1 parent 9ff5916 commit b522785

File tree

2 files changed

+67
-30
lines changed

2 files changed

+67
-30
lines changed

docs/cloudformation/geolocator-web-presence.yml

Lines changed: 67 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ Parameters:
2222
Type: String
2323
Description: ARN of the Lambda@Edge function for injecting security headers to CloudFront
2424
OSEndpoint:
25-
Type: String
25+
Type: AWS::SSM::Parameter::Value<String>
2626
Default: /OpenSearch/Endpoint
2727
Description: OpenSearch endpoint
2828
OSSecretID:
29-
Type: String
29+
Type: AWS::SSM::Parameter::Value<String>
3030
Default: /OpenSearch/SSM
3131
Description: SSM parameter name for OpenSearch user name and password
3232

@@ -41,7 +41,7 @@ Resources:
4141
Role: !GetAtt LambdaExecutionRole.Arn
4242
CodeUri:
4343
Bucket: !Ref DeploymentBucket
44-
Key: cloudformation-templates/lambda/geolocator/geolocator-commit-15b0de5722c2362d49cdfdbdfd2cb9f97c94059e.zip
44+
Key: cloudformation-templates/lambda/geolocator/geolocator-20250618-1200-43817b1.zip
4545
MemorySize: 3009
4646
Handler: index.handler
4747
Timeout: 900
@@ -65,7 +65,7 @@ Resources:
6565
Bucket: !Ref DeploymentBucket
6666
Key: cloudformation-templates/lambda/geolocator/forward-sortation-area-20250615-1200.zip
6767
MemorySize: 3009
68-
Handler: index.handler
68+
Handler: app.lambda_handler
6969
Timeout: 30
7070
Environment:
7171
Variables:
@@ -116,7 +116,7 @@ Resources:
116116
- Effect: Allow
117117
Action:
118118
- secretsmanager:GetSecretValue
119-
Resource: arn:aws:secretsmanager:ca-central-1:${AWS::AccountId}:secret:OpenSearchSecret-geocore-semantic-search-with-opensearch-stage*
119+
Resource: !Sub "arn:aws:secretsmanager:ca-central-1:${AWS::AccountId}:secret:OpenSearchSecret-geocore-semantic-search-with-opensearch-stage*"
120120
- Effect: Allow
121121
Action:
122122
- es:ESHttpGet
@@ -127,7 +127,7 @@ Resources:
127127
- es:ListDomainNames
128128
- es:ESHttpHead
129129
- es:ESHttpPatch
130-
Resource: !Sub arn:aws:es:ca-central-1:${AWS::AccountId}:domain/*/*
130+
Resource: !Sub "arn:aws:es:ca-central-1:${AWS::AccountId}:domain/*/*"
131131

132132
VerificationHeaderSecret:
133133
Type: AWS::SecretsManager::Secret
@@ -246,24 +246,7 @@ Resources:
246246
Name: geolocator
247247
AccessLogSetting:
248248
DestinationArn: !GetAtt LogGroup.Arn
249-
Format: >-
250-
{
251-
"requestId": "$context.requestId",
252-
"ip": "$context.identity.sourceIp",
253-
"caller": "$context.identity.caller",
254-
"user": "$context.identity.user",
255-
"requestTime": "$context.requestTime",
256-
"httpMethod": "$context.httpMethod",
257-
"resourcePath": "$context.resourcePath",
258-
"status": "$context.status",
259-
"protocol": "$context.protocol",
260-
"responseLength": "$context.responseLength",
261-
"errorMessage": "$context.error.message",
262-
"integrationLatency": "$context.integrationLatency",
263-
"apiId": "$context.apiId",
264-
"stage": "$context.stage",
265-
"latency": "$context.latency"
266-
}
249+
Format: '{"requestId":"$context.requestId","ip":"$context.identity.sourceIp","caller":"$context.identity.caller","user":"$context.identity.user","requestTime":"$context.requestTime","httpMethod":"$context.httpMethod","resourcePath":"$context.resourcePath","status":"$context.status","protocol":"$context.protocol","responseLength":"$context.responseLength","errorMessage":"$context.error.message","integrationLatency":"$context.integrationLatency","apiId":"$context.apiId","stage":"$context.stage","latency":"$context.latency"}'
267250
EndpointConfiguration:
268251
Type: REGIONAL
269252
OpenApiVersion: '2.0'
@@ -277,18 +260,72 @@ Resources:
277260
paths:
278261
/:
279262
get:
280-
x-amazon-apigateway-integration:
281-
type: aws_proxy
263+
consumes:
264+
- "application/json"
265+
produces:
266+
- "application/json"
267+
responses: #Method response:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-methodresponse.html
268+
"200":
269+
description: "200 response"
270+
# schema:
271+
# $ref: "#/definitions/Empty"
272+
headers:
273+
Access-Control-Allow-Origin:
274+
type: "string"
275+
x-amazon-apigateway-integration: #Integration response:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-api-gateway-extensions.html
276+
type: aws
282277
httpMethod: POST
283278
uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${Geolocator.Arn}/invocations'
284-
responses: {}
279+
responses:
280+
default:
281+
statusCode: "200"
282+
responseParameters:
283+
method.response.header.Access-Control-Allow-Origin: "'*'"
284+
requestTemplates:
285+
application/json: |
286+
{
287+
"q": "$input.params('q')",
288+
"key": "$input.params('key')",
289+
"keys": "$input.params('keys')",
290+
"lang": "$input.params('lang')",
291+
"table": "$input.params('table')",
292+
"ip_address": "$context.identity.sourceIp",
293+
"timestamp": "$context.requestTimeEpoch",
294+
"user_agent": "$context.identity.userAgent",
295+
"http_method": "$context.httpMethod"
296+
}
285297
/fsa:
286298
get:
287-
x-amazon-apigateway-integration:
288-
type: aws_proxy
299+
consumes:
300+
- "application/json"
301+
produces:
302+
- "application/json"
303+
responses: #Method response:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-methodresponse.html
304+
"200":
305+
description: "200 response"
306+
# schema:
307+
# $ref: "#/definitions/Empty"
308+
headers:
309+
Access-Control-Allow-Origin:
310+
type: "string"
311+
x-amazon-apigateway-integration: #Integration response:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-api-gateway-extensions.html
312+
type: aws
289313
httpMethod: POST
290314
uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ForwardSortationLambda.Arn}/invocations'
291-
responses: {}
315+
responses:
316+
default:
317+
statusCode: "200"
318+
responseParameters:
319+
method.response.header.Access-Control-Allow-Origin: "'*'"
320+
requestTemplates:
321+
application/json: |
322+
{
323+
"q": "$input.params('q')",
324+
"ip_address": "$context.identity.sourceIp",
325+
"timestamp": "$context.requestTimeEpoch",
326+
"user_agent": "$context.identity.userAgent",
327+
"http_method": "$context.httpMethod"
328+
}
292329
geolocatorS3Bucket:
293330
Type: AWS::S3::Bucket
294331
Properties:
20.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)