https://pulumi.com logo
#general
Title
# general
q

quick-airport-30353

03/04/2022, 9:17 PM
I'm using pulumi w/ Python and I'm trying to create an API gateway endpoint for my lambdas (in containers). I was using
aws.apigatewayv2
and followed the examples found on the Pulumi website. The Lambdas and API Gateway resources are provisioned along with the stage but the lambdas are not bound to the API Gateway resources I specified. Is there something I'm doing wrong?
g

great-queen-39697

03/04/2022, 9:26 PM
Can you share a link to which examples you were following? Or a snippet of code (with confidential info redacted)?
q

quick-airport-30353

03/07/2022, 5:09 PM
@great-queen-39697 sorry the delay! I saw this message shortly after logging out fo rthe day.
here is the code:
Copy code
###########################
# Create API Endpoints
###########################
api_gw = aws.apigatewayv2.Api(f"httpApiGateway-{ENVIRONMENT}",
                              protocol_type="HTTP")

health_check_permission = aws.lambda_.Permission("ping_lambda_permission",
                                                 action="lambda:InvokeFunction",
                                                 principal="<http://apigateway.amazonaws.com|apigateway.amazonaws.com>",
                                                 function=lambda_healthcheck
                                                 )

ping_integration = aws.apigatewayv2.Integration(f"health-check-{ENVIRONMENT}",
                                                api_id=api_gw.id,
                                                integration_type="AWS_PROXY",
                                                integration_uri=lambda_healthcheck.arn,
                                                integration_method="GET",
                                                payload_format_version="2.0",
                                                passthrough_behavior="WHEN_NO_MATCH")
ping_route = aws.apigatewayv2.Route(f"ping_route_{ENVIRONMENT}",
                                    api_id=api_gw.id,
                                    route_key="GET /Localization/ping")

stage = aws.apigatewayv2.Stage(f"apiStage-{ENVIRONMENT}",
                               api_id=api_gw.id,
                               name=f"{ENVIRONMENT}",
                               route_settings=[
                                   aws.apigatewayv2.StageRouteSettingArgs(
                                       route_key=ping_route.route_key,
                                       throttling_burst_limit=5000,
                                       throttling_rate_limit=10000
                                   )
                               ],
                               auto_deploy=True)
For now, I'm packaging my lambdas using pulumi.AssetArchive
the lambdas work but API Gateway isn't binding
g

great-queen-39697

03/07/2022, 10:20 PM
As you can tell, I'm a bit behind catching up myself 😅 So I think you're missing a
target
value in the
ping_route
resource. See if this example helps some: https://github.com/pulumi/examples/blob/master/aws-py-apigateway-lambda-serverless/__main__.py
That would be my first check, to be honest.
q

quick-airport-30353

03/08/2022, 3:03 PM
@great-queen-39697 that worked, however, my API integrations are throwing an error sad panda.
g

great-queen-39697

03/08/2022, 10:32 PM
What kind of error are you running into? Can you post them (with confidential info redacted, please!)? I'll see if I can help
7 Views