Nama template
ACS-FC-RunScript
Deskripsi template
Menjalankan skrip Python di Function Compute (FC). Sebelum menggunakan template ini, Anda harus mengaktifkan Function Compute.
Tipe template
Otomatis
Pemilik
Alibaba Cloud
Parameter input
Parameter | Deskripsi | Tipe | Diperlukan | Nilai default | Batasan |
Runtime | Lingkungan runtime. | String | Tidak | python3.10 | |
Skrip | Kode skrip Python. | String | Tidak | | |
FCAssumeRole | Peran RAM yang diasumsikan oleh Function Compute. | String | Tidak | "" | |
OOSAssumeRole | Peran RAM yang diasumsikan oleh CloudOps Orchestration Service (OOS). | String | Tidak | "" |
Parameter output
Parameter | Deskripsi | Tipe |
ScriptOutput | String |
Kebijakan izin yang diperlukan untuk mengeksekusi template
{
"Version": "1",
"Statement": [
{
"Action": [
"ros:CreateStack",
"ros:DeleteStack",
"ros:GetStack"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Detail
Untuk informasi lebih lanjut, lihat ACS-FC-RunScript.yml di GitHub.
Konten Template
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 }}'