initial port of ts simple http api to py
ADD
aws-py-apigatewayv2-http-api-quickcreate/.gitignore
+*.pyc
+venv/

ADD
aws-py-apigatewayv2-http-api-quickcreate/Pulumi.yaml
+name: aws-py-apigatewayv2-http-api-quickstart
+runtime:
+ name: python
+ options:
+ virtualenv: venv
+description: Quickstart example of using AWS API Gateway v2 HTTP API

ADD
aws-py-apigatewayv2-http-api-quickcreate/__main__.py
+# Copyright 2016-2021, Pulumi Corporation. All rights reserved
+
+import pulumi
+import json
+import pulumi_aws as aws
+
+# Create the role for the Lambda to assume
+lambda_role = aws.iam.Role("lambdaRole",
+ assume_role_policy=json.dumps({
+ "Version": "2012-10-17",
+ "Statement": [{
+ "Action": "sts:AssumeRole",
+ "Principal": {
+ "Service": "lambda.amazonaws.com",
+ },
+ "Effect": "Allow",
+ "Sid": "",
+ }]
+ }))
+
+# Attach the fullaccess policy to the Lambda role created above
+role_policy_attachment = aws.iam.RolePolicyAttachment("lambdaRoleAttachment",
+ role=lambda_role,
+ policy_arn=aws.iam.ManagedPolicy.AWS_LAMBDA_BASIC_EXECUTION_ROLE)
+
+# Create the lambda to execute
+lambda_function = aws.lambda_.Function("lambdaFunction",
+ code=pulumi.AssetArchive({
+ ".": pulumi.FileArchive("./app"),
+ }),
+ runtime="nodejs12.x",
+ role=lambda_role.arn,
+ handler="index.handler")
+
+# Give API Gateway permissions to invoke the Lambda
+lambda_permission = aws.lambda_.Permission("lambdaPermission",
+ action="lambda:InvokeFunction",
+ principal="apigateway.amazonaws.com",
+ function=lambda_function)
+
+# Set up the API Gateway
+apigw = aws.apigatewayv2.Api("httpApiGateway",
+ protocol_type="HTTP",
+ route_key="GET /",
+ target=lambda_function.invoke_arn)
+
+# Export the API endpoint for easy access
+pulumi.export("endpoint", apigw.api_endpoint)
\ No newline at end of file

ADD
aws-py-apigatewayv2-http-api-quickcreate/app/index.js
+exports.handler = async function(event, context) {
+ console.log("EVENT: \n" + JSON.stringify(event, null, 2))
+ return {
+ statusCode: 200,
+ body: "Hello, Pulumi!"
+ };
+ }
\ No newline at end of file

ADD
aws-py-apigatewayv2-http-api-quickcreate/requirements.txt
+pulumi>=2.0.0,<3.0.0
+pulumi-aws>=3.2.0,<4.0.0

initial port of ts simple http api to py