Data lakes are a popular choice for today’s organizations to store their data around their business activities. As a best practice of a data lake design, data should be immutable once stored. But regulations such as the General Data Protection Regulation (GDPR) have created obligations for data operators who must be able to erase or update personal data from their data lake when requested.
A data lake built on AWS uses Amazon Simple Storage Service (Amazon S3) as its primary storage environment. When a customer asks to erase or update private data, the data lake operator needs to find the required objects in Amazon S3 that contain the required data and take steps to erase or update that data. This activity can be a complex process for the following reasons:
To handle these situations, a transactional feature on S3 objects is required, and frameworks such as Apache Hudi or Apache Iceberg provide you the transactional feature for upserts in Amazon S3.
AWS contributed the Apache Iceberg integration with the AWS Glue Data Catalog, which enables you to use open-source data computation engines like Apache Spark with Iceberg on AWS Glue. In 2022, Amazon Athena announced support of Iceberg, enabling transaction queries on S3 objects.
In this post, we show you how to stream real-time data to an Iceberg table in Amazon S3 using AWS Glue streaming and perform transactions using Amazon Athena for deletes and updates. We use a serverless mechanism for this implementation, which requires minimum operational overhead to manage and fine-tune various configuration parameters, and enables you to extend your use case to ACID operations beyond the GDPR.
We used the Amazon Kinesis Data Generator (KDG) to produce synthetic streaming data in Amazon Kinesis Data Streams and then processed the streaming input data using AWS Glue streaming to store the data in Amazon S3 in Iceberg table format. As part of the customer’s request, we ran delete and update statements using Athena with Iceberg support.
The following diagram illustrates the solution architecture.

The solution workflow consists of the following steps:
The codebase required for this post is available in the GitHub repository.
Before starting the implementation, make sure the following prerequisites are met:
us-east-1Complete the following steps to deploy your solution resources:

This CloudFormation template configures the following resources in your account:
streamingicebergdemo-XX (note that the XX part is a random unique number to make the S3 bucket name unique)
custdata under the created S3 bucket.
We use Kinesis Data Streams to create a serverless streaming data service that is built to handle millions of events with low latency. The following steps guide you on how to create the data stream in the us-east-1 Region:
us-east-1).
demo-data-stream.On-demand mode works to eliminate the need for provisioning and managing the capacity for streaming data. However, you can implement this solution with Kinesis Data Streams in provisioned mode as well.

demo-data-stream and for it to be in Active status.
To create a sample streaming dataset, we use the KDG URL generated on the CloudFormation stack Outputs tab and log in with the credentials used in the parameters for the CloudFormation template. For this post, we use the following template to generate sample data in the demo-data-stream Kinesis data stream.
us-east-1.demo-data-stream.100 (it can be another number, depending on the rate of record creation).This will start sending 100 records per second in the Kinesis data stream. (To stop sending data, choose Stop Sending Data to Kinesis.)
To add the Apache Iceberg Connector for AWS Glue, complete the following steps. The connector is free to use and supports AWS Glue 1.0, 2.0, and 3.0.






The AWS Glue Data Catalog contains references to data that is used as sources and targets of your extract, transform, and load (ETL) jobs in AWS Glue. To create your data warehouse or data lake, you must catalog this data. The AWS Glue Data Catalog is an index to the location and schema of your data. You use the information in the Data Catalog to create and monitor your ETL jobs.
For this post, we create a Data Catalog database named icebergdemodb containing the metadata information of a table named customer, which will be queried through Athena.
icebergdemodb.This creates an AWS Glue database for metadata storage.
In this step, we create a Data Catalog table in Iceberg table format.
demoworkgroup for SQL queries.For more information about Athena versions, refer to Changing Athena engine versions.


demoworkgroup.icebergdemodb.icerbergdemodb. Note that the TBLPROPERTIES section mentions ICEBERG as the table type and LOCATION points to the S3 folder (custdata) URI created in earlier steps. This DDL command is available on the GitHub repo.
After you run the command successfully, you can see the table customer in the Data Catalog.

In this section, we create the AWS Glue streaming job, which fetches the record from the Kinesis data stream using the Spark script editor.


The sample code keeps appending data in the target location by fetching records from the Kinesis data stream.
Demo\_Job.demojobrole.5.
| Key | Value |
--iceberg\_job\_catalog\_warehouse | s3://streamingicebergdemo-XX/custdata/ |
--output\_path | s3://streamingicebergdemo-XX |
--kinesis\_arn | arn:aws:kinesis:us-east-1:<AWS Account ID>:stream/demo-data-stream |
--user-jars-first | True |

Demo\_Job and choose View run details to check the job run details and Amazon CloudWatch logs.
In this section, we demonstrate a few use cases that are relevant to GDPR alignment with the user data that’s stored in Iceberg format in the Amazon S3-based data lake as implemented in the previous steps. For this, let’s consider that the following requests are being initiated in the workflow to comply with the regulations:
customerid (for example, 59289)phonenumber for the customerid (for example, 51936)The IDs used in this example are samples only because they were created through the KDG template used earlier, which creates sample data. You can search for IDs in your implementation by querying through the Athena query editor. The steps remain the same.
Complete the following steps to fulfill the first use case:
icebergdemodb is chosen as the database.This query gives the count of records for the input customerid before delete.

This query deletes the data for the input customerid as per the workflow generated.

The count should be 0.

Complete the following steps to test the second use case:
icebergdemodb is chosen as the database.This query gives the value for phonenumber before update.

This query updates the data to a dummy value.

You can see the data is updated correctly.

A good practice is to run the VACUUM command periodically on the table because operations like INSERT, UPDATE, DELETE, and MERGE will take place on the Iceberg table. See the following code:

The following are a few considerations to keep in mind for this implementation:
Complete the following steps to clean up the resources you created for this post:
This post explained how you can use the Iceberg table format on Athena to implement GDPR use cases like data deletion and data upserts as required, when streaming data is being generated and ingested through AWS Glue streaming jobs in Amazon S3.
The operations for the Iceberg table that we demonstrated in this post aren’t all of the data operations that Iceberg supports. Refer to the Apache Iceberg documentation for details on various operations.
Dhiraj Thakur is a Solutions Architect with Amazon Web Services. He works with AWS customers and partners to provide guidance on enterprise cloud adoption, migration, and strategy. He is passionate about technology and enjoys building and experimenting in the analytics and AI/ML space.
Rajdip Chaudhuri is Solutions Architect with Amazon Web Services specializing in data and analytics. He enjoys working with AWS customers and partners on data and analytics requirements. In his spare time, he enjoys soccer.