I'm currently want to simulate AWS environment using LocalStack. But upon creating-stacks, the service returned me a error code: 500.
Here's my template file:
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Sample'
Resources:
sample:
Type: AWS::Lambda::Function
Properties:
MemorySize: 256
Timeout: 10
Runtime: nodejs8.10
Handler: /dist/service/src/handler.sample
Code:
Zipfile: lambda.zip
Here's the command i'm trying to run:
aws cloudformation create-stack \
--template-body file://localstack/cloudtemplate.yaml \
--stack-name sample \
--endpoint-url=http://localhost:4581 \
And here's the output:
Unable to parse response (syntax error: line 1, column 54), invalid XML received:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
It seems that the cloudformation endpoint of the localstack doesn't work properly. Am i missing something?
The error you get back from LocalStack
is quite vague so you need to dig in a bit deeper. First of all can you post how you start LocalStack
(is it through Docker and if so what is the exact command line)?
Using Docker and docker-compose:
version: '3'
services:
localstack:
image: localstack/localstack:latest
ports:
- "4567-4584:4567-4584"
- "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
environment:
- SERVICES=cloudformation
- HOSTNAME=localstack
- DEFAULT_REGION=eu-west-2
- PORT_WEB_UI=${PORT_WEB_UI- }
- DEBUG=1
A few things to note here:
DEBUG=1
will give you the exact error in the console you execute the docker-compose from which may (or may not) help you diagnose the actual issueCloudformation
is started (by adding it in the SERVICES
array) and that the appropriate port is opened. The default is 4581 (I am just using the default setup above opening all the ports LocalStack
uses):latest
is used. I had an older version of the image and had issues with Cloudformation
which went away by upgrading to latest. Not sure at which point this was fixed but I guess it does not matter.And to ensure that the issue is not with your template try using one that works, e.g. pick one from here:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html
Using the SQS Queue with Cloudwatch Alarms YAML example the following command works for me:
aws cloudformation create-stack --stack-name myteststack --template-body file://cloudf.yml --endpoint-url=http://localhost:4581
If the above works and you still have issues with your template then at least you know where the issue lies (and maybe you can post the more detailed DEBUG output).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With