AWS Training
Modules Listen Certification

← Data Engineer IV — Role Review

DE4 Lab — provision the stack, break it four ways, tear it down

Target: a real AWS account you are allowed to create resources in, Terraform ≥ 1.10 installed, and the AWS CLI configured. Part 5 needs a Confluent Cloud account; it is optional and marked as such.

Cost: pennies if you tear down the same day. The Glue job runs for under a minute on the smallest worker; the S3 bucket holds a few kilobytes; the KMS key costs a pro-rated share of its monthly price until the deletion window ends; the alarm and log group fall inside the free tier quoted in lesson 4 (10 alarm metrics, 5 GB Logs). Do not create the EMR Serverless application or the Redshift Serverless workgroup from lesson 5's example unless you want to pay for them — the lab doesn't need them.

Predict before you run. Every numbered question asks for a written answer before the command. That is the whole exercise: the stack is small, the reflexes are the point.


Part 1 — Provision with Terraform (lesson 5)

Create a directory and copy the backend block and the aws_kms_key, aws_glue_catalog_database, aws_glue_job, and aws_cloudwatch_metric_alarm resources from lesson 5's working example. Leave out the EMR Serverless, Lambda, Lake Formation, and Redshift resources for now. Add an aws_s3_bucket for scripts and output, and upload a trivial script that reads nothing and writes one Parquet file into the bucket.

terraform init
terraform plan -out=tfplan
terraform apply tfplan

Q1. Before init: with use_lockfile = true in the backend, which three S3 permissions does the role need on the .tflock object, and why does it not need s3:DeleteObject on the state key? (Lesson 5 quotes the page.)

Q2. Run terraform plan -detailed-exitcode immediately after a clean apply. Write the exit code you expect, then run it. Now change the alarm's evaluation_periods in the console by hand and run it again. What exit code did you get, and what does CI do with that number?

Q3. Open the state file in S3 and search for your Glue job. Is the script location there in plain text? Would a sensitive = true variable have changed that? Cite the sentence from lesson 5.


Part 2 — Run the job and read it through the API (lesson 1)

aws glue start-job-run --job-name <your-job-name>
aws glue get-job-run --job-name <your-job-name> --run-id <JobRunId> \
  --query 'JobRun.[JobRunState,StartedOn,CompletedOn,ExecutionTime,ErrorMessage]'

Q4. Write the sequence of JobRunState values you expect to see if you poll every few seconds, then poll and record what you actually saw. Which value from the enum in lesson 1 did you not see, and what would produce it?

Deliberate failure 1 — concurrency. Start the job, and immediately start it again before the first finishes.

Q5. Write the exact exception name you expect, then run it. Which job setting produced it, what is its default, and where would you raise it in Terraform?

Deliberate failure 2 — the bookmark that lies. Enable job bookmarks on the job, run it twice against an S3 input folder, then reset the bookmark and run it a third time.

Q6. After the reset, is the earlier output still in the target? Quote the sentence from the bookmark page that predicts this. What is the one-line design rule that makes bookmarks safe?


Part 3 — Make the alarm honest (lesson 4)

Your alarm from Part 1 watches the Glue failure metric. Look at its TreatMissingData setting.

Q7. The job hasn't run today. What state is the alarm in, and will it ever go to ALARM if the schedule is silently broken? Which of the four TreatMissingData values changes that answer, and what is the trade-off?

Deliberate failure 3 — the silent notification. Put the alarm into ALARM by hand:

aws cloudwatch set-alarm-state --alarm-name <name> --state-value ALARM --state-reason "lab"

Confirm the SNS email arrives. Then delete the SNS topic (not the alarm) and repeat.

Q8. What did the second set-alarm-state return? What arrived? Write the one check you would add to a pipeline's monitoring so a missing topic is itself alarmed.

Q9. Add an EventBridge rule for Glue Job State Change using the pattern copied in lesson 4, targeting the same SNS topic (recreate it). Run the job and trigger failure 1 again. Which event detail types did you receive, and which failure from Part 2 produced no event at all? Why?


Part 4 — Lake Formation, IAM, and KMS (lesson 6)

Add the aws_lakeformation_permissions resource from lesson 5 for a second IAM role you create for "an analyst", granting SELECT on the output table in the catalog database. Apply. Then assume the analyst role and query the table in Athena.

Q10. Before querying: list permissions on the database with aws lakeformation list-permissions. Is IAMAllowedPrincipals present with Super? Predict whether your fine-grained grant is in effect yet, and quote the sentence from lesson 6 that tells you.

Deliberate failure 4 — remove the default, lose access. Revoke IAMAllowedPrincipals' Super on the database and table, then query again as the analyst role, and then as the Glue job role.

Q11. Which of the two principals lost access, and which three places could the denial be coming from? List them in the order you would check, with the command for each.

Q12. Add a data filter restricting the analyst to one partition value. Which Lake Formation permission must the filter be attached to? Query as the analyst and confirm the row count changes.

Q13. Switch the output bucket to SSE-KMS with the aws_kms_key from Part 1. Run the Glue job. If it fails, which policy denied it: the job role's IAM policy, or the key policy? How do you tell the two apart from the error text and from CloudTrail? Then enable S3 Bucket Keys and state, from lesson 6, what changes about the key-policy check for cached requests.

Q14. The KMS request quota in your Region: write the figure from the table (not the prose) in lesson 6, and whether it is adjustable. Why does the lesson tell you to quote the table?


Part 5 (optional) — Confluent Cloud S3 sink (lesson 2)

Needs a Confluent Cloud account; a Basic cluster and a fully-managed S3 sink for under an hour costs very little, but read the current Confluent pricing page first — this lab does not quote it.

Create a topic with 6 partitions, produce a few hundred keyed JSON messages, and create the S3 sink connector with the JSON config copied in lesson 2, pointed at your lab bucket.

Q15. With flush.size at the Cloud minimum for your cluster type and 6 partitions, how many files do you expect in S3 after 300 messages? Count them. Explain the difference.

Q16. Set errors.tolerance to all and produce one message that is not valid JSON. Where did it go, and what header information is present or absent given the context.headers.enable default?

Q17. Which partitioner would let Athena prune this data by date, and which rotation setting would break the connector's exactly-once guarantee if you turned it on? Quote the sentence.


Teardown

# Confluent (if used): delete the connector, then the topic, then the cluster, in the console or CLI.
aws s3 rm s3://<lab-bucket> --recursive
terraform destroy

Then check:


Done when you can

Facilitator notes