forked from aliyun/oos-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathACS::FC::ExecuteScript.json
117 lines (117 loc) · 5.41 KB
/
ACS::FC::ExecuteScript.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{
"Description": "Excute python script.",
"FormatVersion": "OOS-2019-06-01",
"Parameters": {
"runtime": {
"Type": "String",
"Description": "The version of python.",
"AllowedValues": [
"python2.7",
"python3"
]
},
"handler": {
"Type": "String",
"Description": "Python script function name(example:index.handler, index is the file name, handler is the name of the script function.)."
},
"inputPayload": {
"Type": "Json",
"Description": "The parameter value of the script.",
"Default": ""
},
"script": {
"Type": "String",
"Description": "Python script code.",
"Default": ""
},
"attachment": {
"Type": "String",
"Description": "Specify zipFile as the base64 encoded content of the zip package.",
"Default": ""
}
},
"Tasks": [
{
"Name": "createStack",
"Action": "ACS::ExecuteAPI",
"Description": "Create a resource stack.",
"Properties": {
"Service": "ROS",
"API": "CreateStack",
"Parameters": {
"StackName": "OOS-{{ACS::ExecutionId}}",
"TimeoutInMinutes": 10,
"DisableRollback": false,
"Parameters": [
{
"ParameterKey": "ParameterKeys",
"ParameterValue": "{{ inputPayload }}"
},
{
"ParameterKey": "FunctionName",
"ParameterValue": "OOS-{{ACS::ExecutionId}}"
},
{
"ParameterKey": "ServiceName",
"ParameterValue": "OOS-{{ACS::ExecutionId}}"
}
],
"TemplateBody": "{\n \"ROSTemplateFormatVersion\": \"2015-09-01\",\n \"Parameters\": {\n \"ParameterKeys\": {\n \"Type\": \"String\"\n },\n \"ServiceName\": {\n \"Type\": \"String\"\n },\n \"FunctionName\": {\n \"Type\": \"String\"\n },\n \"ExecuteVersion\": {\n \"Type\": \"Number\",\n \"Default\": 0\n }\n },\n \"Resources\": {\n \"Service\": {\n \"Type\": \"ALIYUN::FC::Service\",\n \"Properties\": {\n \"ServiceName\": {\n \"Ref\": \"ServiceName\"\n }\n }\n },\n \"Function\": {\n \"Type\": \"ALIYUN::FC::Function\",\n \"DependsOn\": \"Service\",\n \"Properties\": {\n \"ServiceName\": {\n \"Ref\": \"ServiceName\"\n },\n \"FunctionName\": {\n \"Ref\": \"FunctionName\"\n },\n \"Code\": {\n \"SourceCode\": \"{{ script }}\",\n \"ZipFile\":\"{{ attachment }}\"\n },\n \"Handler\": \"{{ handler }}\",\n \"Runtime\": \"{{ runtime }}\",\n \"Timeout\": 300\n }\n },\n \"FunctionInvoker\": {\n \"Type\": \"ALIYUN::FC::FunctionInvoker\",\n \"DependsOn\": \"Function\",\n \"Properties\": {\n \"ServiceName\": {\n \"Ref\": \"ServiceName\"\n },\n \"FunctionName\": {\n \"Ref\": \"FunctionName\"\n },\n \"Async\": false,\n \"Event\": {\n \"Ref\": \"ParameterKeys\"\n },\n \"ExecuteVersion\": {\n \"Ref\": \"ExecuteVersion\"\n }\n }\n }\n },\n \"Outputs\": {\n \"Result\": {\n \"Value\": {\n \"Fn::Replace\" : [\n {\n \"FcResult\": {\n \"Fn::GetAtt\": [\n \"FunctionInvoker\",\n \"Result\"\n ]\n }\n },\n \"FcResult\"\n ]\n }\n }\n }\n }"
}
},
"Outputs": {
"stackId": {
"Type": "String",
"ValueSelector": "StackId"
}
}
},
{
"Name": "untilStackReady",
"Action": "ACS::WaitFor",
"OnError": "deleteStack",
"Description": "Wait the stack status util CREATE_COMPLETE.",
"Properties": {
"Service": "ROS",
"API": "GetStack",
"Parameters": {
"StackId": "{{createStack.stackId}}"
},
"DesiredValues": [
"CREATE_COMPLETE"
],
"StopRetryValues": [
"CREATE_FAILED",
"CHECK_FAILED",
"ROLLBACK_FAILED",
"ROLLBACK_COMPLETE"
],
"PropertySelector": "Status"
},
"Outputs": {
"result": {
"Type": "String",
"ValueSelector": "Outputs[].OutputValue"
}
}
},
{
"Name": "deleteStack",
"Action": "ACS::ExecuteApi",
"Description": "Delete the stack.",
"Properties": {
"Service": "ROS",
"API": "DeleteStack",
"Parameters": {
"StackId": "{{createStack.stackId}}"
}
}
}
],
"Outputs": {
"Result": {
"Type": "String",
"Value": "{{ untilStackReady.result }}"
}
}
}