Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,10 @@ Resources:
"end": "$input.params('end')",
"org": "$input.params('org')",
"type": "$input.params('type')",
"protocol": "$input.params('protocol')",
"mappable": "$input.params('mappable')",
"theme": "$input.params('theme')",
"topic_category": "$input.params('topic_category')",
"foundational": "$input.params('foundational')",
"source_system": "$input.params('source_system')",
"eo_collection": "$input.params('eo_collection')",
Expand All @@ -588,7 +591,11 @@ Resources:
"order": "$input.params('order')",
"size": "$input.params('size')",
"from": "$input.params('from')",
"userAgent": "$input.params().header.get('User-Agent')"
"ip_address_forward": "$input.params().header.get('X-Forwarded-For')",
"ip_address": "$context.identity.sourceIp",
"timestamp": "$context.requestTimeEpoch",
"user_agent": "$context.identity.userAgent",
"http_method": "$context.httpMethod"
}
options:
consumes:
Expand Down
12 changes: 10 additions & 2 deletions docs/cloudformation/geocore-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4315,8 +4315,16 @@ Resources:
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
requestTemplates:
application/json: "{\r\n \"lang\" : \"$input.params('lang')\",\r\n \
\ \"id\" : \"$input.params('id')\"\r\n}"
application/json: |
{
"lang": "$input.params('lang')",
"id": "$input.params('id')",
"ip_address": "$context.identity.sourceIp",
"ip_address_forward": "$input.params().header.get('X-Forwarded-For')",
"timestamp": "$context.requestTimeEpoch",
"user_agent": "$context.identity.userAgent",
"http_method": "$context.httpMethod"
}
passthroughBehavior: "when_no_templates"
contentHandling: "CONVERT_TO_TEXT"
options:
Expand Down
305 changes: 303 additions & 2 deletions docs/cloudformation/geolocator-web-presence.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Parameters:
Conditions:
IsProd: !Equals [prod, !Ref Environment]

Resources:
Resources:
Geolocator:
Type: AWS::Serverless::Function
Properties:
Expand Down Expand Up @@ -81,6 +81,64 @@ Resources:
Path: /*
Method: any

NTSTwoFiftyKLambda:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.13
Role: !GetAtt LambdaExecutionRole.Arn
CodeUri:
Bucket: !Ref DeploymentBucket
Key: cloudformation-templates/lambda/geolocator/nts-250k-20250725-1200.zip
MemorySize: 3009
Handler: app.lambda_handler
Timeout: 30
Environment:
Variables:
INDEX_NAME: nts-index
MY_AWS_REGION: ca-central-1
OS_ENDPOINT: !Ref OSEndpoint
OS_SECRET_ID: !Ref OSSecretID
Events:
ApiEvent:
Type: Api
Properties:
RestApiId: !Ref RestApi
Path: /*
Method: any
Layers:
- !Sub "arn:aws:lambda:ca-central-1:${AWS::AccountId}:layer:opensearchpy-layer:3"
- arn:aws:lambda:ca-central-1:336392948345:layer:AWSSDKPandas-Python313:3

NRCanGeoLocationLambda:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.13
Role: !GetAtt LambdaExecutionRole.Arn
CodeUri:
Bucket: !Ref DeploymentBucket
Key: cloudformation-templates/lambda/geolocator/nrcan-geolocation-api-20251208-1200.zip
MemorySize: 3009
Handler: lambda_function.lambda_handler
Timeout: 30
Environment:
Variables:
ADDRESS_RANGE_INDEX: geolocation-index-address-range
ANALYTICS_TABLE_NAME: geolocation-analytics-table
INDEX_NAME: geolocation-index
MY_AWS_REGION: ca-central-1
OS_ENDPOINT: !Ref OSEndpoint
OS_SECRET_ID: !Ref OSSecretID
Events:
ApiEvent:
Type: Api
Properties:
RestApiId: !Ref RestApi
Path: /*
Method: any
Layers:
- !Sub "arn:aws:lambda:ca-central-1:${AWS::AccountId}:layer:opensearchpy-layer:3"
- arn:aws:lambda:ca-central-1:336392948345:layer:AWSSDKPandas-Python313:3

LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
Expand Down Expand Up @@ -116,7 +174,7 @@ Resources:
- Effect: Allow
Action:
- secretsmanager:GetSecretValue
Resource: !Sub "arn:aws:secretsmanager:ca-central-1:${AWS::AccountId}:secret:OpenSearchSecret-geocore-semantic-search-with-opensearch-stage*"
Resource: !Sub "arn:aws:secretsmanager:ca-central-1:${AWS::AccountId}:secret:OpenSearchSecret-geocore-semantic-search-with-opensearch-${Environment}*"
- Effect: Allow
Action:
- es:ESHttpGet
Expand Down Expand Up @@ -326,6 +384,249 @@ Resources:
"user_agent": "$context.identity.userAgent",
"http_method": "$context.httpMethod"
}
/nts-250k:
get:
consumes:
- "application/json"
produces:
- "application/json"
responses: #Method response:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-methodresponse.html
"200":
description: "200 response"
# schema:
# $ref: "#/definitions/Empty"
headers:
Access-Control-Allow-Origin:
type: "string"
x-amazon-apigateway-integration: #Integration response:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-api-gateway-extensions.html
type: aws
httpMethod: POST
uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NTSTwoFiftyKLambda.Arn}/invocations'
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
requestTemplates:
application/json: |
{
"q": "$input.params('q')",
"ip_address": "$context.identity.sourceIp",
"timestamp": "$context.requestTimeEpoch",
"user_agent": "$context.identity.userAgent",
"http_method": "$context.httpMethod"
}
/geolocation/en/locate:
get:
consumes:
- "application/json"
produces:
- "application/json"
responses: #Method response:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-methodresponse.html
"200":
description: "200 response"
# schema:
# $ref: "#/definitions/Empty"
headers:
Access-Control-Allow-Origin:
type: "string"
x-amazon-apigateway-integration: #Integration response:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-api-gateway-extensions.html
type: aws
httpMethod: POST
uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NRCanGeoLocationLambda.Arn}/invocations'
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
requestTemplates:
application/json: |
{
"q": "$input.params('q')",
"bbox": "$input.params('bbox')",
"referrer": "$input.params('referrer')",
"ip_address": "$context.identity.sourceIp",
"timestamp": "$context.requestTimeEpoch",
"user_agent": "$context.identity.userAgent",
"http_method": "$context.httpMethod",
"path": "$context.path"
}
/geolocation/en/autocomplete:
get:
consumes:
- "application/json"
produces:
- "application/json"
responses: #Method response:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-methodresponse.html
"200":
description: "200 response"
# schema:
# $ref: "#/definitions/Empty"
headers:
Access-Control-Allow-Origin:
type: "string"
x-amazon-apigateway-integration: #Integration response:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-api-gateway-extensions.html
type: aws
httpMethod: POST
uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NRCanGeoLocationLambda.Arn}/invocations'
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
requestTemplates:
application/json: |
{
"q": "$input.params('q')",
"bbox": "$input.params('bbox')",
"referrer": "$input.params('referrer')",
"ip_address": "$context.identity.sourceIp",
"timestamp": "$context.requestTimeEpoch",
"user_agent": "$context.identity.userAgent",
"http_method": "$context.httpMethod",
"path": "$context.path"
}
/geolocation/en/suggest:
get:
consumes:
- "application/json"
produces:
- "application/json"
responses: #Method response:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-methodresponse.html
"200":
description: "200 response"
# schema:
# $ref: "#/definitions/Empty"
headers:
Access-Control-Allow-Origin:
type: "string"
x-amazon-apigateway-integration: #Integration response:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-api-gateway-extensions.html
type: aws
httpMethod: POST
uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NRCanGeoLocationLambda.Arn}/invocations'
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
requestTemplates:
application/json: |
{
"q": "$input.params('q')",
"bbox": "$input.params('bbox')",
"referrer": "$input.params('referrer')",
"ip_address": "$context.identity.sourceIp",
"timestamp": "$context.requestTimeEpoch",
"user_agent": "$context.identity.userAgent",
"http_method": "$context.httpMethod",
"path": "$context.path"
}
/geolocation/fr/locate:
get:
consumes:
- "application/json"
produces:
- "application/json"
responses: #Method response:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-methodresponse.html
"200":
description: "200 response"
# schema:
# $ref: "#/definitions/Empty"
headers:
Access-Control-Allow-Origin:
type: "string"
x-amazon-apigateway-integration: #Integration response:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-api-gateway-extensions.html
type: aws
httpMethod: POST
uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NRCanGeoLocationLambda.Arn}/invocations'
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
requestTemplates:
application/json: |
{
"q": "$input.params('q')",
"bbox": "$input.params('bbox')",
"referrer": "$input.params('referrer')",
"ip_address": "$context.identity.sourceIp",
"timestamp": "$context.requestTimeEpoch",
"user_agent": "$context.identity.userAgent",
"http_method": "$context.httpMethod",
"path": "$context.path"
}
/geolocation/fr/autocomplete:
get:
consumes:
- "application/json"
produces:
- "application/json"
responses: #Method response:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-methodresponse.html
"200":
description: "200 response"
# schema:
# $ref: "#/definitions/Empty"
headers:
Access-Control-Allow-Origin:
type: "string"
x-amazon-apigateway-integration: #Integration response:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-api-gateway-extensions.html
type: aws
httpMethod: POST
uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NRCanGeoLocationLambda.Arn}/invocations'
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
requestTemplates:
application/json: |
{
"q": "$input.params('q')",
"bbox": "$input.params('bbox')",
"referrer": "$input.params('referrer')",
"ip_address": "$context.identity.sourceIp",
"timestamp": "$context.requestTimeEpoch",
"user_agent": "$context.identity.userAgent",
"http_method": "$context.httpMethod",
"path": "$context.path"
}
/geolocation/fr/suggest:
get:
consumes:
- "application/json"
produces:
- "application/json"
responses: #Method response:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-methodresponse.html
"200":
description: "200 response"
# schema:
# $ref: "#/definitions/Empty"
headers:
Access-Control-Allow-Origin:
type: "string"
x-amazon-apigateway-integration: #Integration response:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-api-gateway-extensions.html
type: aws
httpMethod: POST
uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NRCanGeoLocationLambda.Arn}/invocations'
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
requestTemplates:
application/json: |
{
"q": "$input.params('q')",
"bbox": "$input.params('bbox')",
"referrer": "$input.params('referrer')",
"ip_address": "$context.identity.sourceIp",
"timestamp": "$context.requestTimeEpoch",
"user_agent": "$context.identity.userAgent",
"http_method": "$context.httpMethod",
"path": "$context.path"
}

geolocatorS3Bucket:
Type: AWS::S3::Bucket
Properties:
Expand Down
Loading