Data Ingestion and Transformation · Topic 8 of 8

Programming Concepts and IaC

Apply SQL, Lambda, Git, CI/CD and infrastructure as code with CloudFormation, CDK and SAM to build repeatable, tested data pipelines on AWS.

  • 5 min
In a nutshell
  • CloudFormation is declarative, CDK generates it from code, and SAM simplifies serverless templates.
  • A change set previews a CloudFormation update before it runs.
  • CodePipeline orchestrates, CodeBuild builds and tests, CodeDeploy deploys.

What it is

A data engineer writes code, but also packages, tests and deploys it in a repeatable way. This topic covers the programming habits that the exam expects, not deep software design.

The key ideas are treating infrastructure and pipeline definitions as code, storing them in version control, and releasing them through an automated pipeline.

DevelopercommitpushGit repositoryversion controltriggersCodePipelinestagesCodePipelinestagesbuild and testCodeBuildpackagedeploy stageCloudFormationstack

How it works

Infrastructure as code

Infrastructure as code (IaC) describes resources in files, so an environment can be created, reviewed and rebuilt the same way each time.

ToolWhat it is
AWS CloudFormationDeclarative templates in JSON or YAML, deployed as stacks
AWS CDK (Cloud Development Kit)Define infrastructure in a language such as Python or TypeScript, which generates CloudFormation
AWS SAM (Serverless Application Model)A shorthand extension of CloudFormation for Lambda, API Gateway and related resources
TerraformA third party tool, also used on AWS

A short SAM style template for a Lambda function looks like this.

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  TransformFn:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: src/
      Handler: app.handler
      Runtime: python3.12
      MemorySize: 1024
      Timeout: 300

Stacks support change sets, which preview changes before applying them, and rollback on failure. Parameters and separate stacks per environment keep development and production apart.

CI/CD for data pipelines

Continuous integration (CI) builds and tests every change. Continuous delivery (CD) deploys tested changes through stages. On AWS, AWS CodePipeline orchestrates the stages, AWS CodeBuild runs builds and tests, and AWS CodeDeploy handles some deployment targets, including Lambda.

Store pipeline code, SQL and templates in a Git repository. Common Git actions are git clone, git branch, git commit, git push, git merge and pull requests for review. Teams use branches per feature and merge after review and passing tests.

Lambda for data work

Lambda runs code in response to events without servers. Useful settings for data jobs are memory (which also scales CPU), timeout, and concurrency controls. A Lambda function can run up to 15 minutes.

Lambda layers share libraries between functions, and container images allow larger dependencies. Versions and aliases let you release a new version gradually and roll back. Environment variables hold configuration, while secrets belong in Secrets Manager.

Storage and data APIs in Lambda

Each function has a /tmp directory that is ephemeral and configurable up to 10 GB. For shared or persistent files, mount an Amazon EFS (Elastic File System) file system.

The function must be attached to a VPC, with a mount target reachable from its subnets and a security group that allows NFS. Mounting goes through an EFS access point, and the local mount path must sit under /mnt.

aws lambda update-function-configuration --function-name transform-fn \
  --file-system-configs Arn=arn:aws:elasticfilesystem:us-east-1:123456789012:access-point/fsap-0abc1234,LocalMountPath=/mnt/data

To serve data to other systems, put Amazon API Gateway in front of a Lambda function (or, for simple DynamoDB reads and writes, a direct service integration). The function can run a DynamoDB query, start an Athena query, or call the Redshift Data API. Athena and Redshift answers are not instant, so return a query ID that the client polls, and use pagination tokens for large results.

ControlWhat it does
Stage cache (REST API)Serves repeated identical requests without calling the backend
Throttling and usage plansLimit request rates, per method or per API key
AuthorizersIAM authorization, a Cognito user pool, or a Lambda authorizer decide who may call
Clientother systemHTTPSAPI Gatewayauth and throttleinvokesLambdaquery codereadsAthena or DynamoDB or Redshiftdata store

SQL skills

The exam expects practical SQL: joins, aggregations with GROUP BY, window functions and common table expressions (CTEs). Performance habits matter as much as correctness.

SELECT customer_id,
       order_date,
       SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_date) AS running_total
FROM orders
WHERE order_date >= DATE '2026-01-01';

Select only the columns you need, filter on partition columns, and avoid joining huge tables without a filter. In Redshift, EXPLAIN shows the plan, and sort and distribution keys affect the plan.

Distributed computing and data structures

Spark splits data into partitions and processes them in parallel on many workers. Wide operations such as joins and group by cause a shuffle, where data moves between workers, which is expensive. Reduce shuffles by filtering early and broadcasting small tables.

On data structures, know the idea behind arrays, lists, hash maps, queues, stacks, trees and graphs. A hash map gives fast lookup by key, a queue gives first in first out order, and a graph models relationships such as lineage or networks.

Testing and packaging

Unit test transformation logic with sample data before deploying. Use the SAM command line tool to test Lambda locally. Keep configuration separate from code so the same artifact moves from test to production.

sam build
sam deploy --guided

What to remember for the exam

  • CloudFormation is declarative, CDK generates it from code, and SAM simplifies serverless templates.
  • A change set previews a CloudFormation update before it runs.
  • CodePipeline orchestrates, CodeBuild builds and tests, CodeDeploy deploys.
  • Keep code, SQL and templates in Git, and review changes by pull request.
  • Lambda memory also sets CPU, and the timeout limit is 15 minutes.
  • Lambda versions and aliases support safe releases and rollback.
  • Window functions and CTEs are core SQL skills for transformations.
  • Shuffles are the main cost in distributed joins, so filter early.
Exam tip

"Repeatable and version controlled environment" in a question points to CloudFormation, CDK or SAM, not manual console steps.

Common mistakes

Building by hand in the console. Manual setups drift and cannot be reproduced. Use IaC.

Hardcoding secrets in templates or code. Use Secrets Manager or Systems Manager Parameter Store references.

Confusing CDK and CloudFormation. CDK is a code layer that synthesizes CloudFormation templates, not a separate deployment engine.

Selecting every column. SELECT * on a columnar table reads columns you do not need.

Watch out

A CloudFormation stack that fails during creation rolls back by default, so check the events list for the first failure, not the last.

Check yourself

  • Which tool generates CloudFormation from Python or TypeScript code?

    The AWS CDK.

  • Which AWS service builds and tests code in a pipeline?

    AWS CodeBuild.

  • Why filter early in a Spark join?

    It reduces the data shuffled between workers, which is the costly part.

Topic 8 of 8 in Data Ingestion and Transformation

Test yourself on Data Ingestion and Transformation

The full AWS DEA-C01 question bank has 845 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.