-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Traun Leyden
committed
Feb 25, 2017
1 parent
3e2f908
commit a1ffe99
Showing
3 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
## Deploy to AWS Lambda | ||
|
||
Package the lambda function | ||
|
||
``` | ||
$ wget -O Makefile https://github.com/eawsy/aws-lambda-go-shim/raw/master/src/Makefile.example | ||
$ make | ||
``` | ||
|
||
Deploy cloudformation with lambda function | ||
|
||
``` | ||
$ aws cloudformation package \ | ||
--template-file aws_serverless_application_model.yaml \ | ||
--output-template-file aws_serverless_application_model.out.yaml \ | ||
--s3-bucket cf-templates-1m70kn8ou9eql-us-east-1 | ||
$ aws cloudformation deploy \ | ||
--template-file aws_serverless_application_model.out.yaml \ | ||
--capabilities CAPABILITY_IAM \ | ||
--stack-name CBBootstrapExperiment \ | ||
--region us-east-1 | ||
``` | ||
|
||
Get REST API endpoint | ||
|
||
``` | ||
$ aws cloudformation describe-stacks \ | ||
--stack-name CBBootstrapExperiment \ | ||
--region us-east-1 | grep -i OutputValue | ||
"OutputValue": "https://5e61vqxs5f.execute-api.us-east-1.amazonaws.com/Prod" | ||
``` | ||
|
||
Test endpoint | ||
|
||
``` | ||
$ curl https://5e61vqxs5f.execute-api.us-east-1.amazonaws.com/Prod | ||
``` | ||
|
||
## REST API Definition | ||
|
||
Endpoints | ||
|
||
- POST /cluster/add_or_create | ||
|
||
This creates or updates a cluster object in the system. If it’s the first node in this cluster (defined by cluster_id), then | ||
|
||
Request | ||
|
||
{ | ||
“cluster_id”: “safdasdf3234", | ||
“node_ip_addr_or_hostname”: “ip-233.11.2.5" | ||
} | ||
|
||
Response | ||
|
||
{ | ||
“cluster_already_initialized”: true | false, // if false, then this node becomes the initial node that other nodes try to join | ||
“initial_node_ip_addr_or_hostname”: “ip-233.11.2.5”, // empty if cluster_already_initialized | ||
"all_known_nodes": [ | ||
{ | ||
“node_ip_addr_or_hostname”: “ip-233.11.2.5", | ||
"last_seen": <date> | ||
}, | ||
{ | ||
“node_ip_addr_or_hostname”: “ip-233.11.2.18", | ||
"last_seen": <date> | ||
}, | ||
] | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Resources: | ||
Function: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Handler: handler.Handle | ||
Runtime: python2.7 | ||
CodeUri: ./package.zip | ||
Events: | ||
ApiRoot: | ||
Type: Api | ||
Properties: | ||
Path: / | ||
Method: ANY | ||
ApiGreedy: | ||
Type: Api | ||
Properties: | ||
Path: /{proxy+} | ||
Method: ANY | ||
Outputs: | ||
URL: | ||
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters