You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pulumi version v3.69.0 It runs on AWS cloud. I got errors as follows:
main.py", line 49, in body=pulumi.Output.json_dumps({ AttributeError: type object 'Output' has no attribute 'json_dumps'
Expected Behavior
It should create API Gateway with lambda function.
Steps to reproduce
main.py
"""An AWS Python Pulumi program"""
import json
import iam
import pulumi
import pulumi_aws as aws
#region = 'us-west-2'
region = aws.config.region
custom_stage_name = 'example'
##################
## Lambda Function
##################
# Create a Lambda function, using code from the `./app` folder.
lambda_func = aws.lambda_.Function("mylambda",
role=iam.lambda_role.arn,
runtime="python3.7",
handler="hello.handler",
code=pulumi.AssetArchive({
'.': pulumi.FileArchive('./hello_lambda')
})
)
####################################################################
##
## API Gateway REST API (API Gateway V1 / original)
## /{proxy+} - passes all requests through to the lambda function
##
####################################################################
# Create a single Swagger spec route handler for a Lambda function.
def swagger_route_handler(arn):
return ({
"x-amazon-apigateway-any-method": {
"x-amazon-apigateway-integration": {
"uri": pulumi.Output.format('arn:aws:apigateway:{0}:lambda:path/2015-03-31/functions/{1}/invocations', region, arn),
"passthroughBehavior": "when_no_match",
"httpMethod": "POST",
"type": "aws_proxy",
},
},
})
# Create the API Gateway Rest API, using a swagger spec.
rest_api = aws.apigateway.RestApi("api",
body=pulumi.Output.json_dumps({
"swagger": "2.0",
"info": {"title": "api", "version": "1.0"},
"paths": {
"/{proxy+}": swagger_route_handler(lambda_func.arn),
},
}))
# Create a deployment of the Rest API.
deployment = aws.apigateway.Deployment("api-deployment",
rest_api=rest_api.id,
# Note: Set to empty to avoid creating an implicit stage, we'll create it
# explicitly below instead.
stage_name="",
)
# Create a stage, which is an addressable instance of the Rest API. Set it to point at the latest deployment.
stage = aws.apigateway.Stage("api-stage",
rest_api=rest_api.id,
deployment=deployment.id,
stage_name=custom_stage_name,
)
# Give permissions from API Gateway to invoke the Lambda
rest_invoke_permission = aws.lambda_.Permission("api-rest-lambda-permission",
action="lambda:invokeFunction",
function=lambda_func.name,
principal="apigateway.amazonaws.com",
source_arn=deployment.execution_arn.apply(lambda arn: arn + "*/*"),
)
#########################################################################
# Create an HTTP API and attach the lambda function to it
## /{proxy+} - passes all requests through to the lambda function
##
#########################################################################
http_endpoint = aws.apigatewayv2.Api("http-api-pulumi-example",
protocol_type="HTTP"
)
http_lambda_backend = aws.apigatewayv2.Integration("example",
api_id=http_endpoint.id,
integration_type="AWS_PROXY",
connection_type="INTERNET",
description="Lambda example",
integration_method="POST",
integration_uri=lambda_func.arn,
passthrough_behavior="WHEN_NO_MATCH"
)
url = http_lambda_backend.integration_uri
http_route = aws.apigatewayv2.Route("example-route",
api_id=http_endpoint.id,
route_key="ANY /{proxy+}",
target=http_lambda_backend.id.apply(lambda targetUrl: "integrations/" + targetUrl)
)
http_stage = aws.apigatewayv2.Stage("example-stage",
api_id=http_endpoint.id,
route_settings= [
{
"route_key": http_route.route_key,
"throttling_burst_limit": 1,
"throttling_rate_limit": 0.5,
}
],
auto_deploy=True
)
# Give permissions from API Gateway to invoke the Lambda
http_invoke_permission = aws.lambda_.Permission("api-http-lambda-permission",
action="lambda:invokeFunction",
function=lambda_func.name,
principal="apigateway.amazonaws.com",
source_arn=http_endpoint.execution_arn.apply(lambda arn: arn + "*/*"),
)
# Export the https endpoint of the running Rest API
pulumi.export("apigateway-rest-endpoint", deployment.invoke_url.apply(lambda url: url + custom_stage_name + '/{proxy+}'))
# See "Outputs" for (Inputs and Outputs)[https://www.pulumi.com/docs/intro/concepts/inputs-outputs/] the usage of the pulumi.Output.all function to do string concatenation
pulumi.export("apigatewayv2-http-endpoint", pulumi.Output.all(http_endpoint.api_endpoint, http_stage.name).apply(lambda values: values[0] + '/' + values[1] + '/'))
CLI
Version 3.69.0
Go Version go1.20.4
Go Compiler gc
Plugins
NAME VERSION
aws 5.21.1
aws-apigateway 1.0.1
docker 3.1.0
python unknown
Host
OS ubuntu
Version 22.04
Arch x86_64
This project is written in python: executable='/home/ubuntu/work-on-lambda/cloud/deployment/src/alert_notification_lambda/venv/bin/python3' version='3.9.16
'
Current Stack: company/alert-notification-lambda/stage
TYPE URN
pulumi:pulumi:Stack urn:pulumi:stage::alert-notification-lambda::pulumi:pulumi:Stack::alert-notification-lambda-stage
pulumi:providers:aws urn:pulumi:stage::alert-notification-lambda::pulumi:providers:aws::default_5_21_1
aws:cloudwatch/eventBus:EventBus urn:pulumi:stage::alert-notification-lambda::aws:cloudwatch/eventBus:EventBus::bus
aws:cloudwatch/eventRule:EventRule urn:pulumi:stage::alert-notification-lambda::aws:cloudwatch/eventRule:EventRule::rule
aws:apigatewayv2/api:Api urn:pulumi:stage::alert-notification-lambda::aws:apigatewayv2/api:Api::example
aws:iam/role:Role urn:pulumi:stage::alert-notification-lambda::aws:iam/role:Role::lambda-role
aws:iam/role:Role urn:pulumi:stage::alert-notification-lambda::aws:iam/role:Role::api-gateway-role
aws:apigatewayv2/stage:Stage urn:pulumi:stage::alert-notification-lambda::aws:apigatewayv2/stage:Stage::stage
aws:iam/rolePolicy:RolePolicy urn:pulumi:stage::alert-notification-lambda::aws:iam/rolePolicy:RolePolicy::lambda-role-policy
aws:apigatewayv2/integration:Integration urn:pulumi:stage::alert-notification-lambda::aws:apigatewayv2/integration:Integration::integration
aws:apigatewayv2/route:Route urn:pulumi:stage::alert-notification-lambda::aws:apigatewayv2/route:Route::route
aws:lambda/function:Function urn:pulumi:stage::alert-notification-lambda::aws:lambda/function:Function::lambda
aws:cloudwatch/eventTarget:EventTarget urn:pulumi:stage::alert-notification-lambda::aws:cloudwatch/eventTarget:EventTarget::lambda-target
aws:lambda/permission:Permission urn:pulumi:stage::alert-notification-lambda::aws:lambda/permission:Permission::lambda-permission
Found no pending operations associated with company/stage
Backend
Name pulumi.com
URL https://app.pulumi.com/peter
User peter
Organizations peter, company
Dependencies:
NAME VERSION
boto3 1.26.146
pip 22.0.4
pulumi-aws-apigateway 1.0.1
pulumi-docker 3.1.0
python-dotenv 0.21.0
setuptools 58.1.0
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered:
What happened?
I use the Pulumi sample code at https://github.com/pulumi/examples/tree/master/aws-py-apigateway-lambda-serverless.
pulumi version v3.69.0 It runs on AWS cloud. I got errors as follows:
main.py", line 49, in body=pulumi.Output.json_dumps({ AttributeError: type object 'Output' has no attribute 'json_dumps'
Expected Behavior
It should create API Gateway with lambda function.
Steps to reproduce
main.py
Output of
pulumi about
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered: