Glue_version 和 python_version 在 terraform 中不工作
Glue_version and python_version not working in terraform
大家好,
我正在使用 terraform 来创建胶水作业。现在 AWS Glue 现在支持在 Apache Spark 2.4.3 上 运行 ETL 作业的能力(Python 3)。
我想使用这个功能。但每当我进行更改时,它都会抛出错误。
我在用
aws-cli/1.16.184.
地形 v0.12.6
AWS 提供商 2.29
resource "aws_glue_job" "aws_glue_job_foo" {
glue_version = "1"
name = "job-name"
description = "job-desc"
role_arn = data.aws_iam_role.aws_glue_iam_role.arn
max_capacity = 1
max_retries = 1
connections = [aws_glue_connection.connection.name]
timeout = 5
command {
name = "pythonshell"
script_location = "s3://bucket/script.py"
python_version = "3"
}
default_arguments = {
"--job-language" = "python"
"--ENV" = "env"
"--ROLE_ARN" = data.aws_iam_role.aws_glue_iam_role.arn
}
execution_property {
max_concurrent_runs = 1
}
}
但是它向我抛出错误,
错误:不支持的参数
此处不应有名为 "glue_version" 的参数。
看起来 terraform 使用 python_version
而不是 glue_version
通过使用 python_version = "3"
,您应该使用胶水版本 1.0。 Glue 版本 0.9 不支持 python 3.
这个 Terraform 问题已经 resolved。
Terraform aws_glue_job
现在接受 glue_version
argument。
上一个答案
在 Terraform command
块中有或没有 python_version
,我必须去 AWS 控制台编辑作业并设置 "Glue version"。如果没有这个手动步骤,我的工作就会失败。
解决方法 #1
这个问题已经reported and debated and includes a workaround。
resource "aws_glue_job" "etl" {
name = "${var.job_name}"
role_arn = "${var.iam_role_arn}"
command {
script_location = "s3://${var.bucket_name}/${aws_s3_bucket_object.script.key}"
}
default_arguments = {
"--enable-metrics" = ""
"--job-language" = "python"
"--TempDir" = "s3://${var.bucket_name}/TEMP"
}
# Manually set python 3 and glue 1.0
provisioner "local-exec" {
command = "aws glue update-job --job-name ${var.job_name} --job-update 'Command={ScriptLocation=s3://${var.bucket_name}/${aws_s3_bucket_object.script.key},PythonVersion=3,Name=glueetl},GlueVersion=1.0,Role=${var.iam_role_arn},DefaultArguments={--enable-metrics=\"\",--job-language=python,--TempDir=\"s3://${var.bucket_name}/TEMP\"}'"
}
}
解决方法 #2
resource "aws_cloudformation_stack" "network" {
name = "${local.name}-glue-job"
template_body = <<STACK
{
"Resources" : {
"MyJob": {
"Type": "AWS::Glue::Job",
"Properties": {
"Command": {
"Name": "glueetl",
"ScriptLocation": "s3://${local.bucket_name}/jobs/${var.job}"
},
"ExecutionProperty": {
"MaxConcurrentRuns": 2
},
"MaxRetries": 0,
"Name": "${local.name}",
"Role": "${var.role}"
}
}
}
}
STACK
}
大家好, 我正在使用 terraform 来创建胶水作业。现在 AWS Glue 现在支持在 Apache Spark 2.4.3 上 运行 ETL 作业的能力(Python 3)。 我想使用这个功能。但每当我进行更改时,它都会抛出错误。 我在用 aws-cli/1.16.184. 地形 v0.12.6 AWS 提供商 2.29
resource "aws_glue_job" "aws_glue_job_foo" {
glue_version = "1"
name = "job-name"
description = "job-desc"
role_arn = data.aws_iam_role.aws_glue_iam_role.arn
max_capacity = 1
max_retries = 1
connections = [aws_glue_connection.connection.name]
timeout = 5
command {
name = "pythonshell"
script_location = "s3://bucket/script.py"
python_version = "3"
}
default_arguments = {
"--job-language" = "python"
"--ENV" = "env"
"--ROLE_ARN" = data.aws_iam_role.aws_glue_iam_role.arn
}
execution_property {
max_concurrent_runs = 1
}
}
但是它向我抛出错误,
错误:不支持的参数 此处不应有名为 "glue_version" 的参数。
看起来 terraform 使用 python_version
而不是 glue_version
通过使用 python_version = "3"
,您应该使用胶水版本 1.0。 Glue 版本 0.9 不支持 python 3.
这个 Terraform 问题已经 resolved。
Terraform aws_glue_job
现在接受 glue_version
argument。
上一个答案
在 Terraform command
块中有或没有 python_version
,我必须去 AWS 控制台编辑作业并设置 "Glue version"。如果没有这个手动步骤,我的工作就会失败。
解决方法 #1
这个问题已经reported and debated and includes a workaround。
resource "aws_glue_job" "etl" {
name = "${var.job_name}"
role_arn = "${var.iam_role_arn}"
command {
script_location = "s3://${var.bucket_name}/${aws_s3_bucket_object.script.key}"
}
default_arguments = {
"--enable-metrics" = ""
"--job-language" = "python"
"--TempDir" = "s3://${var.bucket_name}/TEMP"
}
# Manually set python 3 and glue 1.0
provisioner "local-exec" {
command = "aws glue update-job --job-name ${var.job_name} --job-update 'Command={ScriptLocation=s3://${var.bucket_name}/${aws_s3_bucket_object.script.key},PythonVersion=3,Name=glueetl},GlueVersion=1.0,Role=${var.iam_role_arn},DefaultArguments={--enable-metrics=\"\",--job-language=python,--TempDir=\"s3://${var.bucket_name}/TEMP\"}'"
}
}
解决方法 #2
resource "aws_cloudformation_stack" "network" {
name = "${local.name}-glue-job"
template_body = <<STACK
{
"Resources" : {
"MyJob": {
"Type": "AWS::Glue::Job",
"Properties": {
"Command": {
"Name": "glueetl",
"ScriptLocation": "s3://${local.bucket_name}/jobs/${var.job}"
},
"ExecutionProperty": {
"MaxConcurrentRuns": 2
},
"MaxRetries": 0,
"Name": "${local.name}",
"Role": "${var.role}"
}
}
}
}
STACK
}