$ serverless deploy
After deploying, you should see output similar to:
Deploying monopoly-challenge to stage dev (us-east-1)
✔ Service deployed to stack monopoly-challenge-dev (152s)
endpoint: GET - https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/
functions:
simulator: monopoly-challenge-dev-simulator (1.9 kB)
Note: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to http event docs.
After successful deployment, you can call the created application via HTTP:
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
Which should result in response similar to the following (removed input
and proprietys
contents for brevity):
{
"statusCode": 200,
"body": {
"statusCode": 200,
"body": {
"result": {
"winner": {
"money": 125,
"name": "CautiousPlayer"
},
"metrics": {
"rounds": 7
},
"proprietys": [
{
"value": 154,
"rent": 30,
"owner": null
},
...
]
},
"input": ...
}
}
}
You can invoke your function locally by using the following command:
serverless invoke local --function simulator
Which should result in response similar to the following:
{
"statusCode": 200,
"body": {
"statusCode": 200,
"body": {
"result": {
"winner": {
"money": 125,
"name": "CautiousPlayer"
},
"metrics": {
"rounds": 7
},
"proprietys": [
{
"value": 154,
"rent": 30,
"owner": null
},
...
]
},
"input": ""
}
}
}
Alternatively, it is also possible to emulate API Gateway and Lambda locally by using serverless-offline
plugin. In order to do that, execute the following command:
serverless plugin install -n serverless-offline
It will add the serverless-offline
plugin to devDependencies
in package.json
file as well as will add it to plugins
in serverless.yml
.
After installation, you can start local emulation with:
serverless offline
To learn more about the capabilities of serverless-offline
, please refer to its GitHub repository.