简体   繁体   English

如何使用 CloudFormation 更新 AWS Glue 作业

[英]How to use CloudFormation to update AWS Glue Jobs

We have many AWS Glue jobs and we are only updating the job code, which are scripts stored in S3.我们有很多 AWS Glue 作业,我们只更新作业代码,它们是存储在 S3 中的脚本。 The problem is CloudFormation couldn't tell when and when not to update our Glue jobs because all CloudFormation template parameters remain the same after script changes, even the script location is pointing to the same S3 object.问题是 CloudFormation 无法判断何时以及何时不更新我们的 Glue 作业,因为所有 CloudFormation 模板参数在脚本更改后保持不变,即使脚本位置指向相同的 S3 object。

You can use the CloudFormation package command .您可以使用package 命令 This enables you to reference local files in your git repository as scripts for Glue Jobs.这使您能够将 git 存储库中的本地文件引用为 Glue 作业的脚本。 Every time before you deploy to CloudFormation you just run the package command.每次部署到 CloudFormation 之前,您只需运行 package 命令。

As this is similar to Lambda code package, you can use parameterize the Glue script path and then have different versions of Glue script file由于这类似于 Lambda 代码 package,您可以使用参数化 Glue 脚本路径,然后拥有不同版本的 Glue 脚本文件

Glue CFT has "Command" parameter taking in "JobCommand" Type value which includes "ScriptLocation" attribute, make this as a CFT parameter and have the script dynamic Glue CFT 的“Command”参数采用“JobCommand”类型值,其中包括“ScriptLocation”属性,将其作为 CFT 参数并使脚本动态化

{
  "Name" : String,
  "PythonVersion" : String,
  "ScriptLocation" : String
}

You can probably setup a CI/CD pipeline using AWS CodePipeline or your 3rd party CI/CD tool with the below steps您可以通过以下步骤使用 AWS CodePipeline 或您的第 3 方 CI/CD 工具设置 CI/CD 管道

  • Pull the new code from your SCM like Github to deploy S3从您的 SCM 中提取新代码,如 Github 以部署 S3
  • Update CloudFormation stack with new S3 script path (with versions like v1, v2 etc...)使用新的 S3 脚本路径更新 CloudFormation 堆栈(使用 v1、v2 等版本...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM