pulumi / pulumi-aws-apigateway

Apache License 2.0
13 stars 5 forks source link

Unhelpful error when AWS region is not configured #91

Closed thomas11 closed 4 months ago

thomas11 commented 1 year ago

Simple program:

import * as apigateway from "@pulumi/aws-apigateway";

const getHandler = new aws.lambda.CallbackFunction("GET", {
    policies: [aws.iam.ManagedPolicy.AWSLambdaVPCAccessExecutionRole, aws.iam.ManagedPolicy.LambdaFullAccess],
    callback: async (ev, ctx) => {
        [...]
    },
});

// Create an API endpoint
const endpoint = new apigateway.RestAPI("hello-world", {
    routes: [{
        path: "/{route+}",
        method: "GET",
        eventHandler: getHandler,
    }],
});

exports.endpoint = endpoint.url;

Running pulumi up without AWS_REGION set:

Diagnostics:
  aws:apigateway:RestApi (hello-world):
    error: 1 error occurred:
        * creating urn:pulumi:tkappler::aws-ts-apigateway::aws-apigateway:index:RestAPI$aws:apigateway/restApi:RestApi::hello-world: 1 error occurred:
        * creating API Gateway REST API (gou81ynktb) specification: BadRequestException: Errors found during import:
        Unable to put integration on 'GET' for resource at path '/{route+}': Invalid ARN specified in the request

This is because the region becomes part of the endpoint URL. "Invalid ARN" doesn't help the user figure this out, though.