Live-coding the Cloud!
Portkey allows, at the REPL, to expose any function as an AWS Lambda.
Almost any inanimate object can be turned into a Portkey. Once bewitched, the object will transport anyone who grasps it to a pre-arranged destination.
The sensation of travelling by Portkey is universally agreed to be uncomfortable, if not downright unpleasant, and can lead to nausea, giddiness and worse.
(source)
Live at the repl:
(defn flatter [name]
(str name " is " (rand-nth ["incredible" "awesome" "fantastic"])))
(pk/mount! flatter "/hello?name={name}")
=> {:url "https://api-id.execute-api.region.amazonaws.com/hello"}
Go to "https://api-id.execute-api.region.amazonaws.com/hello?name=Rich" (and wait for the instance to start).
lein install
(portkey is still alpha so not on clojars yet).[portkey "0.1.0-SNAPSHOT"]
to your project file.First steps:
Next steps:
fdef
specs could be leveraged to validate Lambda input.The following AWS service actions are used by portkey, define them in for example an inline policy for a IAM user:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Resource": "*",
"Action": [
"lambda:GetPolicy",
"lambda:GetFunction",
"lambda:GetFunctionConfiguration",
"lambda:AddPermission",
"lambda:CreateFunction",
"lambda:UpdateFunctionCode",
"lambda:InvokeFunction",
"lambda:UpdateFunctionConfiguration",
"lambda:DeleteFunction",
"apigateway:*",
"iam:GetRole",
"iam:CreateRole",
"iam:PutRolePolicy",
"iam:PassRole",
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups",
"ec2:DescribeVpcs",
"s3:PutObject",
"s3:GetObject"
]
}
]
}
Copyright © 2017 Christophe Grand and Kimmo Koskinen
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.