From ad155bcff4592d1923850bc86728c0f860ee0095 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 22 Nov 2020 12:15:47 +0800 Subject: [PATCH] feat: add fun template.yml --- README.md | 6 ++++++ template.toml | 18 ++++++++++++++++++ {{project_name}}/justfile | 2 ++ {{project_name}}/template.yml | 23 +++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 {{project_name}}/template.yml diff --git a/README.md b/README.md index 1345514..77a4e85 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Use this template you need to install: * Kickstart - https://crates.io/crates/kickstart * Docker - https://github.com/docker/docker-ce * Dockerbuild - https://crates.io/crates/dockerbuild +* Fun and Config Fun - https://github.com/alibaba/funcraft * Just - https://crates.io/crates/just @@ -30,6 +31,11 @@ Deploy: ![](https://playsecurity.org/getdoc/4033_25BD84287DA6F33F8498764CD2ACA299/aliyun_custom_fn.png) +Build and deploy: +```shell +$ just builddeply +``` +
Sample output: diff --git a/template.toml b/template.toml index d0472bd..62a9e72 100644 --- a/template.toml +++ b/template.toml @@ -47,3 +47,21 @@ choices = [ name = "description" default = "A Alibaba Cloud Function application" prompt = "A short description of the app?" + +[[variables]] +name = "fnservice" +default = "my-service" +prompt = "You fn service name?" +validation = "^([a-zA-Z][a-zA-Z0-9_-]+)$" + +[[variables]] +name = "fnfunction" +default = "my-function" +prompt = "You fn function name?" +validation = "^([a-zA-Z][a-zA-Z0-9_-]+)$" + +[[variables]] +name = "fnevent" +default = "None" +prompt = "Your fn http event(or None)?" +validation = "^([a-zA-Z][a-zA-Z0-9_-]+)$" diff --git a/{{project_name}}/justfile b/{{project_name}}/justfile index 7607239..6c7abf1 100644 --- a/{{project_name}}/justfile +++ b/{{project_name}}/justfile @@ -8,3 +8,5 @@ buildfn: zip code.zip bootstrap {{bin}} rm {{bin}} +builddeply: buildfn + fun deploy diff --git a/{{project_name}}/template.yml b/{{project_name}}/template.yml new file mode 100644 index 0000000..287ed9d --- /dev/null +++ b/{{project_name}}/template.yml @@ -0,0 +1,23 @@ +ROSTemplateFormatVersion: '2015-09-01' +Transform: 'Aliyun::Serverless-2018-04-03' +Resources: + {{fnservice}}: + Type: 'Aliyun::Serverless::Service' + Properties: + Description: '{{description}}' + {{fnfunction}}: + Type: 'Aliyun::Serverless::Function' + Properties: + Handler: index.handler + MemorySize: 128 + CodeUri: './code.zip' + Description: '{{description}}' + Runtime: custom +{% if fnevent != "None" -%} + Events: + {{fnevent}}: + Type: HTTP + Properties: + AuthType: ANONYMOUS + Methods: ['GET', 'POST', 'PUT'] +{%- endif %}