从模板创建工作流 - Amazon Transfer Family
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

从模板创建工作流

您可以部署用于创建工作流程的Amazon CloudFormation堆栈和基于模板的服务器。此过程包含一个示例,您可以使用该示例来快速部署工作流程。

创建用于创建Amazon Transfer Family工作流程和服务器的Amazon CloudFormation堆栈
  1. 打开 Amazon CloudFormation 控制台,地址:https://console.aws.amazon.com/cloudformation

  2. 将以下代码保存到一个文件中。

    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": "Amazon::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" } ] } } } }
  3. 将以下项目替换为您的实际值。

    • workflow-execution-role-arn 替换为实际工作流执行角色的 ARN。例如,arn:aws:transfer:us-east-2:111122223333:workflow/w-1234567890abcdef0

    • arn:aws:lambda:region:account-id:function:function-name替换为您的 Lambda 函数的 ARN。例如,arn:aws:lambda:us-east-2:123456789012:function:example-lambda-idp

  4. 按照《Amazon CloudFormation用户指南》中的选择Amazon CloudFormation堆栈模板中的从现有模板部署堆栈的说明进行操作

部署堆栈后,您可以在 CloudFormation 控制台的 Outputs 选项卡中查看有关堆栈的详细信息。该模板创建了一个新的Amazon Transfer Family SFTP 服务器供用户使用服务管理的用户,并创建了一个新的工作流程,并将工作流与新服务器关联起来。