aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Is it possible to use aws libraries against the sam-local server?

Open tedbrandston opened this issue 9 years ago • 5 comments

Some of my lambda functions use other lambda functions that are not part of the api. For services like dynamodb or sqs I can pass --endpoint-url (aws-cli) or endpoint_url (boto3) to point at dynamodb-local or fake-sqs. I haven't been able to get that to work with sam-local and lambdas, which makes a certain amount of sense to me.

Is there a different way to have my local lambdas call other local lambdas without the lambda code reflecting it? (I realize I could do if (sam_local) { import x, x.blah() } else { lambda.invoke(...) }, but I'd rather not, if possible.

tedbrandston avatar Nov 15 '17 15:11 tedbrandston

how about sending an http request to your other lambda endpoints?

purefan avatar Nov 16 '17 07:11 purefan

under the hood it's the same thing, I think? The point is that unless you expose them via an Event: Type: Api it doesn't look like they're exposed for http traffic.

Maybe I'm just misunderstanding sam-local, but I was hoping to be able to use the same cloudformation template for local/staging/prod. There are some lambda functions that you don't want to expose in staging/prod.

tedbrandston avatar Nov 16 '17 14:11 tedbrandston

Just to get a better understanding, what you want is: aws --endpoint "https://localhost:8123/" lambda invoke --function-name "RESOURCE_NAME" /dev/null

To work in a sane way, just like dynamodb-local has it's api reflected?

iph avatar Nov 17 '17 17:11 iph

yep.

tedbrandston avatar Nov 17 '17 21:11 tedbrandston

Duplicate of #12.

This is something we'd like to do, but I don't have any further information on timescales. We'd welcome any pull requests in this area if you wanted to take a stab at it.

PaulMaddox avatar Nov 25 '17 10:11 PaulMaddox