feat: add fun template.yml

This commit is contained in:
2020-11-22 12:15:47 +08:00
parent 7cda98a9b8
commit ad155bcff4
4 changed files with 49 additions and 0 deletions

View File

@@ -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
```
<br>
Sample output:

View File

@@ -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_-]+)$"

View File

@@ -8,3 +8,5 @@ buildfn:
zip code.zip bootstrap {{bin}}
rm {{bin}}
builddeply: buildfn
fun deploy

View File

@@ -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 %}