Skip to content

Commit

Permalink
Merge pull request #25 from ThiagoPanini/develop
Browse files Browse the repository at this point in the history
Funcionalidade de agendamento de job Glue via Terraform
  • Loading branch information
ThiagoPanini authored Dec 30, 2022
2 parents 0e79a8b + e84a842 commit 2d862f7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions INFRA.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ Ao acessar o job através do console e navegar até o menu *Job details* (ou det
</div>
</details>

Além disso, no menu *Schedules*, será possível visualizar um agendamento criado automaticamente via Terraform para execução do *job* Glue com uma expressão cron fornecida como exemplo (`cron(0 21 ? * 6 *)`) simulando o gatilho de execução todas às sextas-feiras às 21h00m. Para maiores detalhes, o usuário poderá consultar o [recurso `aws_glue_trigger`](https://github.com/ThiagoPanini/terraglue/blob/main/infra/modules/glue/main.tf#L49) no módulo glue presente no diretório de infra.

___

### Dados na camada SoT
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,6 @@ Todos são muito bem vindos a contribuírem com evoluções e novas funcionalida
- [SparkByExamples - Pyspark Date Functions](https://sparkbyexamples.com/pyspark/pyspark-sql-date-and-timestamp-functions/)
- [Spark - Configuration Properties](https://spark.apache.org/docs/latest/configuration.html)
- [Stack Overflow - repartition() vs coalesce()](https://stackoverflow.com/questions/31610971/spark-repartition-vs-coalesce)
- [Semantic Release](https://semver.org/)
- [GitHub - Angular Commit Message Format](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#-commit-message-format)
- [commitlint](https://github.com/conventional-changelog/commitlint)
1 change: 1 addition & 0 deletions infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,5 @@ module "glue" {
glue_job_python_version = var.glue_job_python_version
glue_job_max_concurrent_runs = var.glue_job_max_concurrent_runs
glue_job_default_arguments = local.glue_job_default_arguments
glue_job_trigger_cron_expr = var.glue_job_trigger_cron_expr
}
13 changes: 13 additions & 0 deletions infra/modules/glue/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ as configurações necessárias de acordo com as melhroes
práticas de implementação deste serviço.
RESOURCES: Os recursos aqui implantados serão:
- Objetos no S3 com insumos do job
- Glue Job
- Trigger para Glue Job
-------------------------------------------------- */

# Realizando o upload da aplicação Spark para o S3
Expand Down Expand Up @@ -43,3 +45,14 @@ resource "aws_glue_job" "this" {

default_arguments = var.glue_job_default_arguments
}

# Declarando trigger para agendamento de job glue
resource "aws_glue_trigger" "job_trigger" {
name = "trigger-${var.glue_job_name}"
type = "SCHEDULED"
schedule = var.glue_job_trigger_cron_expr

actions {
job_name = var.glue_job_name
}
}
5 changes: 5 additions & 0 deletions infra/modules/glue/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ variable "glue_job_default_arguments" {
description = "Dicionário contendo mapeamentos para todos os argumentos e seus respectivos valores configurados para o job do glue"
type = map(string)
}

variable "glue_job_trigger_cron_expr" {
description = "Expressão cron responsável pelo agendamento do job do Glue na AWS"
type = string
}
6 changes: 6 additions & 0 deletions infra/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,9 @@ variable "glue_job_user_arguments" {
"--NUM_PARTITIONS" = 5
}
}

variable "glue_job_trigger_cron_expr" {
description = "Expressão cron responsável pelo agendamento do job do Glue"
type = string
default = "cron(0 21 ? * 6 *)"
}

0 comments on commit 2d862f7

Please sign in to comment.