テンプレート名
ACS-FC-RunScript
テンプレートの説明
Function Compute (FC) で Python スクリプトを実行します。このテンプレートを使用する前に、Function Compute を有効化する必要があります。
テンプレートの種類
自動化
所有者
Alibaba Cloud
入力パラメーター
パラメーター | 説明 | 種類 | 必須 | デフォルト値 | 制限 |
ランタイム | ランタイム環境。 | 文字列 | いいえ | python3.10 | |
スクリプト | Python スクリプトコード。 | 文字列 | いいえ | | |
FCAssumeRole | Function Compute によって引き受けられる RAM ロール。 | 文字列 | いいえ | "" | |
OOSAssumeRole | CloudOps Orchestration Service (OOS) によって引き受けられる RAM ロール。 | 文字列 | いいえ | "" |
出力パラメーター
パラメーター | 説明 | 種類 |
ScriptOutput | 文字列 |
テンプレートの実行に必要な権限ポリシー
{
"Version": "1",
"Statement": [
{
"Action": [
"ros:CreateStack",
"ros:DeleteStack",
"ros:GetStack"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
詳細
詳細については、GitHub の ACS-FC-RunScript.yml をご参照ください。
テンプレートコンテンツ
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 }}'