Skip to content

Commit

Permalink
Use Api gateway v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Almeida committed May 4, 2022
1 parent 3305b9e commit fad6c04
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stack/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

# Export the DNS name of the bucket
pulumi.export("bucket_name", infra.bucket.url)
pulumi.export("titiler_sentinel_url", titiler_sentinel.lambda_deployment.invoke_url)
pulumi.export("titiler_sentinel_url", titiler_sentinel.lambda_api.api_endpoint)
23 changes: 23 additions & 0 deletions stack/titiler_sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,28 @@ def create_package(code_dir: str) -> pulumi.FileArchive:
principal="apigateway.amazonaws.com",
function=lambda_titiler_sentinel,
)
lambda_api = aws.apigatewayv2.Api(
construct_name("lambda-titiler-api"), protocol_type="HTTP"
)
lambda_integration = aws.apigatewayv2.Integration(
construct_name("lambda-titiler-integration"),
api_id=lambda_api.id,
integration_type="AWS_PROXY",
)
lambda_route = aws.apigatewayv2.Route(
construct_name("lambda-titiler-route"),
api_id=lambda_api.id,
route_key="ANY /{proxy+}",
target=f"integrations/{lambda_integration.id}",
)
lambda_stage = aws.apigatewayv2.Stage(
construct_name("lambda-titiler-stage"),
api_id=lambda_api.id,
name="$default",
auto_deploy=True,
opts=pulumi.ResourceOptions(depends_on=[lambda_route]),
)
"""
lambda_rest_api = aws.apigateway.RestApi(
construct_name("lambda-titiler-rest-api"), name="Titiler Sentinel"
)
Expand Down Expand Up @@ -153,3 +175,4 @@ def create_package(code_dir: str) -> pulumi.FileArchive:
rest_api=lambda_rest_api.id,
stage_name="default",
)
"""

0 comments on commit fad6c04

Please sign in to comment.