---
title: "Automating the Klarna Card Ownership Fees System using AWS Step Functions"
description: "Klarna replaced a manual, roughly three-business-day monthly routine for charging Klarna Card ownership fees with a scheduled AWS Step Functions workflow."
url: "https://swe.quest/articles/automating-the-klarna-card-ownership-fees-system-using-aws-step-functions-c726ac59ac2b16c2"
canonical: "https://engineering.klarna.com/automating-the-klarna-card-ownership-fees-system-using-aws-step-functions-346ce7094278"
source: "Klarna Engineering"
published: "2024-05-02"
difficulty: "medium"
kind: "Case study"
reading_minutes: 8
tags: ["cloud","infrastructure-as-code","scheduling","payments","typescript"]
---

# Automating the Klarna Card Ownership Fees System using AWS Step Functions

A post on [Klarna Engineering](https://swe.quest/sources/klarna.md), published 2024-05-02, 8 min read, Case study. Original: [https://engineering.klarna.com/automating-the-klarna-card-ownership-fees-system-using-aws-step-functions-346ce7094278](https://engineering.klarna.com/automating-the-klarna-card-ownership-fees-system-using-aws-step-functions-346ce7094278)

## Summary

Klarna replaced a manual, roughly three-business-day monthly routine for charging Klarna Card ownership fees with a scheduled AWS Step Functions workflow. The routine had two engineers running Athena checks, launching Glue jobs in sequence and reviewing the results. The existing pipeline (PySpark Glue jobs feeding SQS, a decision-tree Lambda, and DynamoDB) is now orchestrated by a CDK-defined state machine. The post shows code for LambdaInvoke and synchronous GlueStartJobRun tasks, JSONPath argument passing, least-privilege IAM roles and an EventBridge cron schedule. The automation cut team workload by 12.5% per month and reduced human-error risk, with Datadog/OpsGenie alerting on failures and a caveat that Glue jobs can't be invoked cross-region or cross-account.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)
- [Infrastructure as code](https://swe.quest/tags/infrastructure-as-code.md) (Infrastructure)
- [Scheduling](https://swe.quest/tags/scheduling.md) (Distributed systems)
- [Payments & fintech](https://swe.quest/tags/payments.md) (Domains)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)

## Prerequisites

- AWS Lambda and Glue ([easy posts on Cloud platforms](https://swe.quest/tags/cloud.md?difficulty=easy))
- AWS CDK basics ([easy posts on Cloud platforms](https://swe.quest/tags/cloud.md?difficulty=easy))
- IAM roles ([easy posts on Identity & auth](https://swe.quest/tags/identity-auth.md?difficulty=easy))

## Keywords

AWS Step Functions, AWS CDK, AWS Glue, EventBridge Scheduler, Amazon States Language, Klarna Card, SQS

## Related posts

- [How Zillow runs 100 million daily notifications on AWS Step Functions](https://swe.quest/articles/how-zillow-runs-100-million-daily-notifications-on-aws-step-functions-43ac4ec68597baa8.md): AWS Architecture Blog · 2026-11-11 · Medium · 15 min read · Serverless, Communications, System design, Cloud platforms, Configuration management
  Zillow replaced more than 10 per-campaign notification generator services with a configuration-driven Campaign Orchestrator that runs each of 100M+ daily email and push notifications as a short-lived AWS Step Functions Express Workflow, calling a shared library of stateless, schema-driven content modules (the Universal Content Generator) via HTTP Invoke.
- [Modular regression testing framework built on AWS for large-scale systems](https://swe.quest/articles/modular-regression-testing-framework-built-on-aws-for-large-scale-systems-5423a76854a0e19b.md): AWS Architecture Blog · 2026-11-12 · Medium · 14 min read · Testing, Deployment, CI/CD, Serverless, Cloud platforms
  A traffic-replay regression testing framework built on AWS captures production requests and responses, replays a sample against new code in pre-production, and gates deployments on a CloudWatch alarm over the fraction of matching outputs (typically 99.9%).
- [Building an Auto-Scaling Lambda based on Github's Workflow Job Queue](https://swe.quest/articles/building-an-auto-scaling-lambda-based-on-github-s-workflow-job-queue-4077ceef4fa411b3.md): ClickHouse · 2023-06-15 · Medium · 2 min read · CI/CD, Capacity planning, Cloud platforms, Serverless, Cost optimization
  ClickHouse replaced CloudWatch-alarm-based EC2 Auto Scaling for its self-hosted GitHub Actions runners with a Lambda that reads the workflow job queue, built from GitHub webhook events stored in ClickHouse, and sets desired capacity directly.
- [How Country Road Group built a pattern-driven integration solution on AWS](https://swe.quest/articles/how-country-road-group-built-a-pattern-driven-integration-solution-on-aws-10204ddba48d4959.md): AWS Architecture Blog · 2026-11-19 · Medium · 10 min read · Event-driven architecture, Serverless, Infrastructure as code, Refactoring & migrations, Cloud platforms
  Country Road Group replaced 21 BizTalk Server interfaces on VMware with a declarative, pattern-driven integration platform on AWS, where each interface is composed from standard enterprise integration patterns provisioned by pre-built Terraform modules.
- [Workflows are coming to Supabase](https://swe.quest/articles/workflows-are-coming-to-supabase-a57ed34660f0256b.md): Supabase · 2021-04-02 · Medium · 5 min read · Serverless, PostgreSQL, Elixir & Erlang, Scheduling, Event-driven architecture
  Supabase is building Workflows, an open source orchestration engine written in Elixir that uses the Amazon States Language to coordinate existing functions (AWS, GCP, Azure, OpenFaaS, Postgres) in response to database events or HTTP calls.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
