AWS Glue 使用 Tools for PowerShell V4 的範例 - AWS Tools for PowerShell (第 4 版)

第 5 版 (V5) AWS Tools for PowerShell 已發行!

若要開始使用新版本的工具,請參閱 AWS Tools for PowerShell 使用者指南 (V5),特別是遷移至 V5 的主題。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

AWS Glue 使用 Tools for PowerShell V4 的範例

下列程式碼範例示範如何使用 AWS Tools for PowerShell V4 搭配 來執行動作和實作常見案例 AWS Glue。

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境中查看內容中的動作。

每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

以下程式碼範例顯示如何使用 New-GLUEJob

Tools for PowerShell V4

範例 1:此範例會在 Glue AWS 中建立新的任務。命令名稱值一律為 glueetl. AWS Glue,支援執行以 Python 或 Scala 撰寫的任務指令碼。在此範例中,任務指令碼 (MyTestGlueJob.py) 以 Python 撰寫。Python 參數在 $DefArgs 變數中指定,然後在 DefaultArguments 參數中傳遞至 PowerShell 命令,該命令接受雜湊表。$JobParams變數中的參數來自 CreateJob API,記載於 Glue API 參考的任務 (https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-jobs-job.html://) AWS 主題。

$Command = New-Object Amazon.Glue.Model.JobCommand $Command.Name = 'glueetl' $Command.ScriptLocation = 's3://amzn-s3-demo-source-bucket/admin/MyTestGlueJob.py' $Command $Source = "source_test_table" $Target = "target_test_table" $Connections = $Source, $Target $DefArgs = @{ '--TempDir' = 's3://amzn-s3-demo-bucket/admin' '--job-bookmark-option' = 'job-bookmark-disable' '--job-language' = 'python' } $DefArgs $ExecutionProp = New-Object Amazon.Glue.Model.ExecutionProperty $ExecutionProp.MaxConcurrentRuns = 1 $ExecutionProp $JobParams = @{ "AllocatedCapacity" = "5" "Command" = $Command "Connections_Connection" = $Connections "DefaultArguments" = $DefArgs "Description" = "This is a test" "ExecutionProperty" = $ExecutionProp "MaxRetries" = "1" "Name" = "MyOregonTestGlueJob" "Role" = "Amazon-GlueServiceRoleForSSM" "Timeout" = "20" } New-GlueJob @JobParams
  • 如需 API 詳細資訊,請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》中的 CreateJob