Lesson 2 of 9 Data Engineering Practices

Keeping Pipelines in Version Control

This lesson explains how keeping pipeline code, SQL, infrastructure templates and configuration in version control makes every change reviewable, every release reproducible and every mistake reversible.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify what belongs in version control.
  • Apply Git practices such as branches and pull requests.
  • Connect Git repositories to AWS services.

What belongs in version control

The test for version control is simple: everything needed to rebuild a pipeline from nothing should be in the repository. That includes the transformation code, whether PySpark, Python, Scala or SQL; the infrastructure templates written with AWS CloudFormation, the AWS CDK or AWS SAM; the orchestration definitions, such as Step Functions state machine definitions and Apache Airflow DAGs; the configuration for each environment; and the data quality rulesets that validate the pipeline's output.

Secrets are the exception. Passwords, API keys and connection strings with credentials never belong in a repository, where anyone with read access, and every clone, would hold them. They are stored in AWS Secrets Manager and referenced by name from code and templates.

Sort into groups

In the repository?

Exam skills 1.4.4

Decide whether each item belongs in the pipeline's Git repository.

Log in to try this activity Interactive activities are free with an account.

Working with Git

Pipeline code, SQL and infrastructure templates belong in Git, hosted on a service such as GitHub, GitLab or Bitbucket, and teams follow a few practices. Each change is developed on a feature branch, so unfinished work never affects the main branch. A pull request asks to merge the branch, and a second person reviews the logic, tests and security before it is accepted. Tags mark each released version, so whatever is running in production can be identified and rebuilt exactly. Commit messages linked to tickets record why each change was made. The following table summarises the practices.

PracticePurpose
Feature branchesIsolate work in progress from the main branch
Pull requests and code reviewA second person checks logic, tests and security
Tags for releasesAny deployed version can be identified and rebuilt
Commit messages linked to ticketsExplain why a change was made

The following diagram shows what a team draws on to reproduce a report from several months ago exactly.

Reproducing the 31 March report. The release tag v2.7.0 identifies the Glue job script, the Step Functions definition and the data quality ruleset that were deployed that day, and the raw zone still holds the 31 March input unchanged. Rerunning the tagged code against the preserved input in a test account reproduces the report.
Secrets are not in the repository; the code refers to them by name.
Match the pairs

Git practices

Exam skills 1.4.4

Match each Git practice with its purpose.

Log in to try this activity Interactive activities are free with an account.

Connecting Git to AWS

AWS services integrate with Git repositories in several ways. Glue jobs can be pushed to and pulled from Git repositories; AWS CodeConnections links GitHub, GitLab and Bitbucket to CodePipeline; and SageMaker Unified Studio projects use Git for notebooks and code. Infrastructure changes then flow from a merged pull request to deployment through CI/CD.

Worked example

Reproducing last month's numbers

Auditors ask how a regulatory report was produced on 31 March. The pipeline has changed several times since. Because the team versions everything, the answer comes from Git, as the following table shows.

ArtefactVersion used on 31 March
Glue job scriptRelease tag v2.7.0
Step Functions definitionThe same tag, deployed by CloudFormation
Data quality rulesetStored in the repository at that tag
Input dataRaw zone partitions for 31 March, unchanged

Checking out the tag and rerunning the job in a test account against the preserved raw data reproduces the report exactly. The pull request history also shows who approved each change and why.

Check yourself

Why tag releases in Git?

Show answer

So any deployed version of the pipeline can be identified and rebuilt exactly.

Exam Tips

Remember for the exam

  • Keep pipeline code, SQL, infrastructure and configuration in Git.
  • Review changes through pull requests before they reach the main branch.
  • Tag releases so any deployed version can be rebuilt.
  • Never commit secrets; reference them from Secrets Manager.
  • Glue jobs can be synchronised with Git repositories.