Nom du modèle
ACS-FC-RunScript
Description du modèle
Ce modèle exécute un script Python dans Function Compute (FC). Vous devez activer Function Compute avant d'utiliser ce modèle.
Type de modèle
Automatisé
Propriétaire
Alibaba Cloud
Paramètres d'entrée
|
Parameter |
Description |
Type |
Required |
Default value |
Limit |
|
Runtime |
Environnement d'exécution du script. |
String |
Non |
python3,10 |
|
|
Script |
Code du script Python à exécuter. |
String |
Non |
|
|
|
FCAssumeRole |
Rôle RAM utilisé par Function Compute. |
String |
Non |
"" |
|
|
OOSAssumeRole |
Rôle RAM utilisé par CloudOps Orchestration Service (OOS). |
String |
Non |
"" |
Paramètres de sortie
|**Parameter**
|
**Description**
|
**Type**
| | --- | --- | --- | |
ScriptOutput
| |
String
|
Stratégie d'autorisation requise
{
"Version": "1",
"Statement": [
{
"Action": [
"ros:CreateStack",
"ros:DeleteStack",
"ros:GetStack"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Détails
Pour plus d'informations, consultez le fichier ACS-FC-RunScript.yml sur GitHub.
Contenu du modèle
FormatVersion: OOS-2019-06-01
Description:
en: FC runs script(Only support python), To use this template, you must first <a href='https://www.alibabacloud.com/help/zh/functioncompute/getting-started/quickly-create-a-function#p-t79-y7o-68z' target="_blank">activate the function computing service< /a>
name-en: ACS-FC-RunScript
Parameters:
Runtime:
Type: String
Label:
en: Runtime
AllowedValues:
- python3.9
- python3.10
Default: python3.10
Script:
Type: String
Label:
en: Python Script
AssociationProperty: ALIYUN::OOS::Command::CommandContent
AssociationPropertyMetadata:
CommandType: RunPythonScript
Default: |-
import datetime
import os
import sys
def _now(format="%Y-%m-%d %H:%M:%S"):
return datetime.datetime.now().strftime(format)
def job_start():
return ("[%s][%s] job_start" % (_now(), os.getpid()))
def handler(event, context):
return job_start()
FCAssumeRole:
Label:
en: FCAssumeRole
Description:
en: The Function Compute platform will use this RAM role to generate a temporary key for accessing your Alibaba Cloud resources and pass it to your code. For details, please see <a href="https://www.alibabacloud.com/help/zh/functioncompute/user-guide/grant-function-compute-permissions-to-access-other-alibaba-cloud-services" target="_blank ">Grant Function Compute permissions to access other cloud services</a>
Type: String
AssociationProperty: ALIYUN::RAM::Service::Role
AssociationPropertyMetadata:
Service: fc.aliyuncs.com
Default: ''
OOSAssumeRole:
Label:
en: OOSAssumeRole
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: ExecuteScript
Action: ACS::FC::ExecuteScript
Description:
en: Run the python script
Properties:
runtime: '{{ Runtime }}'
script: '{{ Script }}'
role: '{{ FCAssumeRole }}'
Outputs:
Result:
Type: String
ValueSelector: Result
Outputs:
ScriptOutput:
Type: String
Value: '{{ ExecuteScript.Result }}'