本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
通过模板创建工作流
您可以部署用于创建工作流的 AWS CloudFormation 堆栈和基于模板的服务器。此过程包含一个示例,您可以使用该示例来快速部署工作流程。
创建用于创建 AWS Transfer Family 工作流程和服务器的 AWS CloudFormation 堆栈
-
在 https://console.aws.amazon.com/cloudformat ion 上打开 AWS CloudFormation 控制台。
-
将以下代码保存到文件中。
- YAML
-
AWSTemplateFormatVersion: 2010-09-09
Resources:
SFTPServer:
Type: 'AWS::Transfer::Server'
Properties:
WorkflowDetails:
OnUpload:
- ExecutionRole: workflow-execution-role-arn
WorkflowId: !GetAtt
- TransferWorkflow
- WorkflowId
TransferWorkflow:
Type: AWS::Transfer::Workflow
Properties:
Description: Transfer Family Workflows Blog
Steps:
- Type: COPY
CopyStepDetails:
Name: copyToUserKey
DestinationFileLocation:
S3FileLocation:
Bucket: archived-records
Key: ${transfer:UserName}/
OverwriteExisting: 'TRUE'
- Type: TAG
TagStepDetails:
Name: tagFileForArchive
Tags:
- Key: Archive
Value: yes
- Type: CUSTOM
CustomStepDetails:
Name: transferExtract
Target: arn:aws:lambda:region
:account-id
:function:function-name
TimeoutSeconds: 60
- Type: DELETE
DeleteStepDetails:
Name: DeleteInputFile
SourceFileLocation: '${original.file}'
Tags:
- Key: Name
Value: TransferFamilyWorkflows
- JSON
-
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"SFTPServer": {
"Type": "AWS::Transfer::Server",
"Properties": {
"WorkflowDetails": {
"OnUpload": [
{
"ExecutionRole": "workflow-execution-role-arn
",
"WorkflowId": {
"Fn::GetAtt": [
"TransferWorkflow",
"WorkflowId"
]
}
}
]
}
}
},
"TransferWorkflow": {
"Type": "AWS::Transfer::Workflow",
"Properties": {
"Description": "Transfer Family Workflows Blog",
"Steps": [
{
"Type": "COPY",
"CopyStepDetails": {
"Name": "copyToUserKey",
"DestinationFileLocation": {
"S3FileLocation": {
"Bucket": "archived-records",
"Key": "${transfer:UserName}/"
}
},
"OverwriteExisting": "TRUE"
}
},
{
"Type": "TAG",
"TagStepDetails": {
"Name": "tagFileForArchive",
"Tags": [
{
"Key": "Archive",
"Value": "yes"
}
]
}
},
{
"Type": "CUSTOM",
"CustomStepDetails": {
"Name": "transferExtract",
"Target": "arn:aws:lambda:region
:account-id
:function:function-name
",
"TimeoutSeconds": 60
}
},
{
"Type": "DELETE",
"DeleteStepDetails": {
"Name": "DeleteInputFile",
"SourceFileLocation": "${original.file}"
}
}
],
"Tags": [
{
"Key": "Name",
"Value": "TransferFamilyWorkflows"
}
]
}
}
}
}
-
将以下值替换为您的实际值。
-
Replace(替换) workflow-execution-role-arn
使用ARN用于实际工作流程执行角色。例如,arn:aws:transfer:us-east-2:111122223333:workflow/w-1234567890abcdef0
-
为您的 Lambda 函数替换arn:aws:lambda:region
:account-id
:function:function-name
ARN为。例如,arn:aws:lambda:us-east-2:123456789012:function:example-lambda-idp
。
-
按照《AWS CloudFormation 用户指南》中的选择 AWS CloudFormation 堆栈模板中的使用现有模板部署堆栈的说明进行操作。
部署堆栈后,您可以在 CloudFormation 控制台的 Outputs 选项卡中查看有关堆栈的详细信息。该模板创建了一个使用服务管理用户的新 AWS Transfer Family SFTP服务器和一个新的工作流,并将该工作流与新服务器相关联。