With AWS Glue Knowledge Catalog views you’ll be able to create a SQL view within the Knowledge Catalog that references a number of base tables. These multi-dialect views help numerous SQL question engines, offering constant entry throughout a number of Amazon Internet Companies (AWS) companies together with Amazon Athena, Amazon Redshift Spectrum, and Apache Spark in each Amazon EMR and AWS Glue 5.0.
Now you can create Knowledge Catalog views utilizing a cross-account AWS Id and Entry Administration (IAM) definer function. A definer function is an IAM function used to create the Knowledge Catalog view and has SELECT permissions on all columns of the underlying base tables. This definer function is assumed by AWS Glue and AWS Lake Formation service principals to vend credentials to the bottom tables’ knowledge every time the view is queried. The definer function permits the Knowledge Catalog view to be shared to principals or AWS accounts so that you could share a filtered subset of knowledge with out sharing the bottom tables.
Beforehand, Knowledge Catalog views required a definer function inside the identical AWS account as the bottom tables. The introduction of cross-account definer roles permits Knowledge Catalog view creation in enterprise knowledge mesh architectures. On this setup, database and desk metadata is centralized in a governance account, and particular person knowledge proprietor accounts keep management over desk creation and administration by their IAM roles. Knowledge proprietor accounts can now create and handle Knowledge Catalog views within the central governance accounts utilizing their current steady integration and steady supply (CI/CD) pipeline roles.
On this submit, we present you a cross-account state of affairs involving two AWS accounts: a central governance account containing the tables and internet hosting the views and an information proprietor (producer) account with the IAM function used to create and handle views. We offer implementation particulars for each SPARK dialect utilizing AWS SDK code samples and ATHENA dialect utilizing SQL instructions. Utilizing this method, you’ll be able to implement refined knowledge governance fashions at enterprise scale whereas sustaining operational effectivity throughout your AWS setting.
Key advantages
Key advantages for cross-account definer roles are as follows:
- Enhanced knowledge mesh help – Enterprises with multi-account knowledge lakehouse architectures can now keep their current operational mannequin the place knowledge proprietor accounts handle desk creation and updates utilizing their established IAM roles. These identical roles can now create and handle Knowledge Catalog views throughout account boundaries.
- Strengthened safety controls – By holding desk and examine administration inside knowledge proprietor account roles:
- Safety posture is enhanced by correct separation of duties.
- Audit trails turn out to be extra complete and significant.
- Entry controls comply with the precept of least privilege.
- Elimination of knowledge duplication – Knowledge proprietor accounts can create views in central accounts that:
- Present entry to particular knowledge subsets with out duplicating tables.
- Scale back storage prices and administration overhead.
- Keep a single supply of reality whereas enabling focused knowledge sharing.
Answer overview
An instance buyer has a database with two transaction tables of their central account, the place the catalog and permissions are maintained. With the database shared to the information proprietor (producer) account, we create a Knowledge Catalog view within the central account on these two tables, utilizing the producer’s definer function. The view from the central account might be shared to extra shopper accounts and queried. We illustrate creating the SPARK dialect utilizing create-table CLI, and add the ATHENA dialect for a similar view from the Athena console. We additionally present the AWS SDK pattern code for CreateTable() and UpdateTable(), with view definition and a pattern pySpark script to learn and confirm the view in AWS Glue.
The next diagram reveals the desk, view, and definer IAM function placements between a central governance account and knowledge producer account.

Stipulations
To carry out this answer, you have to have the next conditions:
- Two AWS accounts with AWS Lake Formation arrange. For particulars, seek advice from Arrange AWS Lake Formation. The Lake Formation setup consists of registering your IAM admin function as Lake Formation administrator. Within the Knowledge Catalog settings, proven within the following screenshot, Default permissions for newly created databases and tables is ready to make use of Lake Formation permissions solely. Cross-account model settings is ready to Model 4.

- Create an IAM function
Knowledge-Analystwithin the producer account. For the IAM permissions on this function, seek advice from Knowledge analyst permissions. This function will even be used because the view definer function. Add the permissions to this definer function from the Stipulations for creating views.
Create database and tables within the central account
On this step, you create two tables within the central governance account and populate them with few rows of knowledge:
- Check in to the central account as admin consumer. Open the Athena console and arrange the Athena question outcomes bucket.
- Run the next queries to create two pattern Iceberg tables, representing financial institution buyer transactions knowledge:
- Confirm the created tables in Athena question editor by working a preview.
Share the database and tables from central to producer account
Within the central governance account, you share the database and the 2 tables to the producer account and the Knowledge-Analyst function in producer.
- Check in to the Lake Formation console because the Lake Formation admin function.
- Within the navigation pane, select Knowledge permissions.
- Select Grant and supply the next info:
- For Principals, choose Exterior accounts and enter the producer account ID, as proven within the following screenshot.

- For Named Knowledge Catalog Sources, choose the default catalog and database
bankdata_icebergdb, as proven within the following screenshot.

- Below Database permissions, choose Describe. For Grantable permissions, choose Describe.

- Select Grant.
- Repeat the previous steps to grant entry to the producer account definer function
Knowledge-Analyston the databasebankdata_icebergdband the 2 tablestransaction_table1andtransaction_table2as follows. - Below Database permissions, grant Create desk and Describe permissions.

- Below Desk permissions, grant Choose and Describe on all columns.

- For Principals, choose Exterior accounts and enter the producer account ID, as proven within the following screenshot.
With these steps, the central governance account knowledge admin steward has shared the database and tables to the producer account definer function.
Steps for producer account
Observe these steps for the producer account:
- Check in to the Lake Formation console on the producer account because the Lake Formation administrator.
- Within the left navigation pane, select Databases. A blue banner will seem on the console, exhibiting pending invites from AWS Useful resource Entry Supervisor (AWS RAM).
- Open the AWS RAM console and evaluation the AWS RAM shares underneath Shared with me. You will notice the AWS RAM shares in pending state. Choose the pending AWS RAM share from central account and select Settle for useful resource share. After the useful resource share request is accepted, the shared database reveals up within the producer account.
- On the Lake Formation console, choose the database. On the Create dropdown record, select Useful resource hyperlink. Present a reputation
rl_bank_icebergand select Create. - Let’s grant Describe permission on the useful resource hyperlink to the
Knowledge-Analystfunction within the producer account within the following steps.- Within the left navigation pane, select Knowledge permissions. Select the
Knowledge-Analystfunction. Choose the useful resource hyperlinkrl_bank_icebergfor the database as proven within the following screenshot.

- Grant Describe permission on the useful resource hyperlink.

- Within the left navigation pane, select Knowledge permissions. Select the
Be aware: Cross-account Knowledge Catalog views can’t be created utilizing a useful resource hyperlink, though a useful resource hyperlink is required for the SDK use of SPARK dialect.
Subsequent, add the central account Knowledge Catalog as a Knowledge Supply in Athena from producer account:
- Open the Athena console.
- On the left navigation pane, select Knowledge sources and catalogs. Select Create knowledge supply.
- Choose S3-AWS Glue Knowledge Catalog.
- Select AWS – Glue Knowledge Catalog in one other account and identify the information supply as
centraladmin. - Select Subsequent after which create knowledge supply.
After the information supply is created, navigate to the Question editor and confirm the Knowledge supply centraladmin seems, as proven within the following screenshot.

The definer function also can now entry and question the central catalog database.
Create SPARK dialect view
On this step, you create a view with SPARK dialect, utilizing AWS Glue CLI command create-table:
- Check in to the AWS console within the producer account as
Knowledge-Analystfunction. Enter the next command in your CLI setting, equivalent to AWS CloudShell, to create a SPARK DIALECT:
- Open the Lake Formation console and confirm if the view is created. Confirm the dialect of the view on the SQL definitions tab for the view particulars.

Add ATHENA dialect
So as to add ATHENA dialect, comply with these steps:
- On the Athena console, choose
centraladminfrom the Knowledge supply. - Enter the next SQL script to create the ATHENA dialect for a similar view:
We will’t use the useful resource hyperlink rl_bank_iceberg within the Athena question editor to create or alter a view within the central account.
- Confirm the added dialect by working a preview in Athena. For working the question, you should utilize both the useful resource hyperlink
rl_bank_icebergfrom the producer account catalog or use thecentraladmincatalog.
The next screenshot reveals querying utilizing the useful resource hyperlink of the database within the producer account catalog.

The next screenshot reveals querying the view from the producer utilizing the related catalog centraladmin as the information supply.

- Confirm the dialects on the view by inspecting the desk within the Lake Formation console.
Now you can question the view because the Knowledge-Analyst function within the producer account, utilizing each Athena and Spark. The view will even present within the central account as proven within the following code instance, with entry to the Lake Formation admin.
You may as well create the view with ATHENA dialect and add the SPARK dialect. The SQL syntax to create the view in ATHENA dialect is proven within the following instance:
The update-table CLI so as to add the corresponding SPARK dialect is proven within the following instance:
The next is a pattern Python script to create a SPARK dialect view: glueview-createtable.py.
The next code block is a pattern AWS Glue extract, switch, and cargo (ETL) script to entry the Spark dialect of the view from AWS Glue 5.0 from the central account. The AWS Glue job execution function ought to have Lake Formation SELECT permission on the AWS Glue view:
Within the AWS Glue job-details, for Lake Formation managed tables and for Iceberg tables, set extra parameters respectively as follows:
Cleanup
To keep away from incurring prices, clear up the assets you used for this submit:
- Revoke the Lake Formation permissions granted to the Knowledge-Analyst function and Producer account
- Drop the Athena tables
- Delete the Athena question outcomes out of your Amazon Easy Storage Service (Amazon S3) bucket
- Delete the
Knowledge-Analystfunction from IAM
Conclusion
On this submit, we demonstrated how you can use cross-account IAM definer roles with AWS Glue Knowledge Catalog views. We confirmed how knowledge proprietor accounts can create and handle views in a central governance account whereas sustaining safety and management over their knowledge property. This characteristic permits enterprises to implement refined knowledge mesh architectures with out compromising on safety or requiring knowledge duplication.
The flexibility to make use of cross-account definer roles with Knowledge Catalog views offers a number of key benefits:
- Streamlines view administration in multi-account environments
- Maintains current CI/CD workflows and automation
- Enhances safety by centralized governance
- Reduces operational overhead by eliminating the necessity for knowledge duplication
As organizations proceed to construct and scale their knowledge lakehouse architectures throughout a number of AWS accounts, cross-account definer roles for Knowledge Catalog views present an important functionality for implementing environment friendly, safe, and well-governed knowledge sharing patterns.
Concerning the authors

