Hey, i'm probably missing something really simple ...
# general
s
Hey, i'm probably missing something really simple but i'm getting the following when trying to deploy an api gateway backed by lambda
Copy code
error: 1 error occurred:
    	* Error creating API Gateway Deployment: BadRequestException: The REST API doesn't contain any methods
(using python) i'm specifying an OpenAPI spec for the body of
aws.apigateway.RestApi
which has routes and methods configured. Not sure what i'm maybe missing somewhere, new to Pulumi (coming from Serverless Framework)
l
Are you using the aws or awsx package?
s
aws Crosswalk isn't available for python is it?
l
There is smidge of support for it, but I've just checked and it doesn't include apigateway..
The error is in creating the Deployment. How are you providing the RestApi to the Deployment? Can you share a little code?
s
Copy code
api_gateway = apigateway.RestApi(
    resource_name='api-gateway',
    body="""swagger: "2.0"
info:
  version: "2021-03-29T15:07:58Z"
  title: "marv"
basePath: "/dev"
schemes:
- "https"
paths:
  /test:
    post:
      responses: {}
      x-amazon-apigateway-integration:
        uri: "REDACTED"
        httpMethod: "POST"
        passthroughBehavior: "when_no_match"
        type: "aws_proxy"""
)

api_gateway_deployment = apigateway.Deployment(
    resource_name='api-gateway-deployment',
    rest_api=api_gateway.id,
    opts=pulumi.ResourceOptions(depends_on=[api_gateway])
)

api_gateway_stage = apigateway.Stage(
    resource_name='marv-api-gateway-stage',
    stage_name='dev',
    rest_api=api_gateway.id,
    deployment=api_gateway_deployment.id
)
l
Sorry got called afk. Just checking, is there a typo or is the line
type: "aws_proxy"""
supposed to have only 3 double-quotes? There's here-doc opener up on the
body
line, and a string opener on the line in question.. seems like there should be 4 double-quotes?
s
4 double quotes throws up an invalid OpenAPI input error when running pulumi up
l
Then one double-quote to close the body field, and three double-quotes on another line to close the heredoc? As it is now, it looks unbalanced...
s
cheers for the point in the right direction @little-cartoon-10569 It was down to the general formatting of the yaml string even though it was seemingly valid as it wasnt error the spec. Rather than placing the string directly i'm loading separate spec file with pyYAML and dumping it out. so just:
Copy code
with open(r'api.yaml') as file:
    openapi_spec = yaml.load(file, Loader=yaml.FullLoader)
and then updating the creation of the RestAPI resource
Copy code
api_gateway = apigateway.RestApi(
    resource_name='api-gateway',
    body=yaml.dump(openapi_spec)
)
l
That's certainly more readable 🙂
s
🙂