Closed prasaddls closed 10 months ago
I got same on windows 10 with localstack-pro latest tried to downgrade localstack-pro to 2.2.0, 2.3.0 and 3.0.0 versions and deployment worked but they are not useful for lambda at all with serverless projects /installed via npm/ serverless examples modified according to serverless-localstack plugin are not working
localstack tried to spin up docker containers for nodejs but failing , seems they create local container but got error : no such container ... for python it kind of working but throwing error that event['body'] was null ... or response not in json format . all this is working from awslocal , but to practice serverless and cdk are not
I increased memorySize property for function executions , gave lambda timeout config 300 but still no result was using different configs for Lambda Executor but still no result localstack couldn't do simplest thing localstack-demo which is on website is not working at all it can't even deploy on latest localstack ... I was not able to use it for any ways and also configs and how to start... them please I used docker-compose.yaml file that is standard given by localstack itself serverless-examples repo projects not working they are repeating existing serverless examples repo and there is no configuration or way how to run projects given
can someone from localstack team give us working examples of serverless projects for node and python languages ? and which version of what was used ?
thanks
Hi @prasaddls,
thanks for reaching out!
can someone from localstack team give us working examples of serverless projects
Please check our Serverless Transcription App, where we use the serverless framework to deploy node-js functions. It contains a very detailed README, I hope you find it helpful!
serverless-examples repo projects not working
Sorry about your experience here! It's a forked repo that is not maintained. In general we are currently trying to setup more samples in the localstack-samples organization.
Regarding the original issue: Unfortunately, I wasn't able yet to reproduce the error you have reported with TemplateURL must be a supported URL
.
You are saying it's not working with localstack/localstack-pro:latest
but it does work with 3.0.0
and lower versions, right?
I am using docker compose and localstack as well
I assume you mean, you tried starting localstack using the cli (localstack start
) and using a docker-compose file, and you get the same error?
Could you try to enable the DEBUG=1
flag, and check if there any errors logged in LocalStack (e.g. the container logs)?
I say the same issue today (on linux).
The logs says:
Overriding S3 templateUrl to http://localhost:4566/
Looking at the source: https://github.com/localstack/serverless-localstack/blob/master/src/index.js#L672-L673 it looks like its replacing the aws url without the trailing slash. The result on my machine is that the template url becomes:
http://localhost:4566//floorplan-converter-local-serverlessdeploymentbuck-cba42efa/serverless/floorplan-converter/local/1704380511014-2024-01-04T15:01:51.014Z/compiled-cloudformation-template.json
Note: the double slash after the port number.
This is the interesting parts of my log when running sls deploy --stage local
:
lifecycle:command:invoke:hook: [79] < aws:deploy:deploy:updateStack
Using custom endpoint for CloudFormation: http://localstack:4566/
Overriding S3 templateUrl to http://localstack:4566/
Skipping reconfiguring of endpoints (already reconfigured)
aws: [16] { name: 'CloudFormation',
params:
{ credentials:
EnvironmentCredentials { expired: false, expireTime: null, refreshCallbacks: [], accessKeyId: 'test', sessionToken: undefined, envPrefix: 'AWS' },
endpoint: 'http://localstack:4566/',
region: 'eu-west-1',
isS3TransferAccelerationEnabled: false } } updateStack [ { StackName: 'floorplan-converter-local',
Capabilities: [ 'CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM' ],
Parameters: [],
Tags: [ { Key: 'STAGE', Value: 'local' } ],
TemplateURL:
'http://localstack:4566//floorplan-converter-local-serverlessdeploymentbuck-cba42efa/serverless/floorplan-converter/local/1704380511014-2024-01-04T15:01:51.014Z/compiled-cloudformation-template.json',
NotificationARNs: [] } ]
aws: [16] { Error [ValidationError]: TemplateURL must be a supported URL.
Digging further into this it looks like the issue might be related to the function:
/**
* If the given `endpointURL` points to `localhost`, then inject the given `hostname` into the URL
* and return it. This helps fix IPv6 issues with node v18+ (see also getConnectHostname() above)
*/
injectHostnameIntoLocalhostURL(endpointURL, hostname) {
const url = new URL(endpointURL);
if (hostname && url.hostname === 'localhost') {
url.hostname = hostname;
}
return url.href;
}
as the href
property includes a trailing slash:
> new URL("http://localstack:4566")
URL {
href: 'http://localstack:4566/',
origin: 'http://localstack:4566',
protocol: 'http:',
username: '',
password: '',
host: 'localstack:4566',
hostname: 'localstack',
port: '4566',
pathname: '/',
search: '',
searchParams: URLSearchParams {},
hash: ''
}
Changing the return value to be return url.origin;
seems to fix my issue.
thanks so much for your input @jorgenfb!
Indeed it seems like this behavior is caused by setting the env AWS_ENDPOINT_URL
.
Please let me know if you would like to issue a PR to fix this?
Not setting the AWS_ENDPOINT_URL
will use the default http://localhost:4566
, which might be a suitable workaround for you @prasaddls?
I've added a PR to fix the issue :)
Thanks so much @jorgenfb!
We merged the fix, but we still need to prepare the release, which will probably go out next week! /cc @prasaddls
We just published serverless-localstack 1.1.3
Here is my serverless.yml
I am getting the following error while trying to deploy: [ I am using docker compose and localstack as well]