Question: How can I troubleshoot Lake Formation permission errors in AWS Glue?

My AWS Glue crawler or ETL job fails with an AWS Lake Formation related error. But, I configured the required AWS Identity and Access Management (IAM) permissions.

Short descriptionTo access resources such as, the AWS Glue Data Catalog and Amazon Simple Storage Service (Amazon S3), you must have the correct IAM policies and Lake Formation permissions. When an IAM role that's associated with your Amazon S3 crawler or ETL job doesn't have sufficient Lake Formation permissions, you get an error. You must have the correct Lake Formation permissions to read and write to and from the following resources:Database and table in the Data CatalogUnderlying data in Amazon S3ResolutionAccess issues when creating Data Catalog databaseIf Data Catalog database creation issues are causing the error, then you get an error message similar to the following one:Insufficient Lake Formation permission(s): Required Create Database on CatalogTo resolve this error, use the data lake administrator role to access the Lake Formation console. Then, grant the Create database permission to the relevant IAM role.Open the AWS Lake Formation console.In the navigation pane, under Permissions, choose Administrative roles and tasks.Under Database creators, choose Grant.For IAM users and roles, from the dropdown list, choose the IAM role that you want to grand access to.Under Catalog permissions, choose Create database.If you want the IAM role to grant permissions to other roles in your account, then under Grantable permissions, choose Create database.Choose Grant.Access issues with Data Catalog databaseIf Data Catalog database issues are causing the error, then you get an error message similar to one of the following one:Insufficient Lake Formation permission(s) on example_database: Required Create TableInsufficient Lake Formation permission(s) on example_database: (Database name: example_database)Insufficient Lake Formation permission(s) on example_table (Database name: example_database, Table Name: example_table)To resolve the first and third errors, grant the Create table permission for example_database to the IAM role that's associated with the crawler or ETL job.To resolve the second error, grant the Describe permission for example_database to the IAM role that's associated with the crawler or ETL job.Open the Lake Formation console.In the navigation pane, under Permissions, choose Data lake permissions.Choose Grant.Under Principals, choose IAM users and roles.For IAM users and roles, choose the IAM role that's associated with the crawler.Under LF-Tags or catalog resources, choose Named data catalog resources.For Databases, choose the database that your crawler is writing to.Under Database permissions, choose Create table or Describe based on your use case. Note: The crawler role must have both Describe AND Create Table permissions on the database that it's writing to. For AWS Glue ETL, these permissions are also sufficient, unless you're running an UpdateDatabase or DeleteDatabase API call from the job itself. In these cases, grant Alter or Drop permissions.If you want the IAM role to grant permissions to other roles in your account, then set permissions under Grantable permissions.Choose Grant.Access issues with Data Catalog tableIf Data catalog table issues are causing the error is caused, then you get an error message similar to one of the following one:Insufficient Lake Formation permission(s) on example_table (Database name: example_database, Table Name: example_table)Insufficient Lake Formation permission(s): Required Alter on example_tableIf you receive this error, then the AWS Glue crawler or ETL job is accessing the table. For the crawler, grant Describe and Alter permissions for example_table to the IAM role that's associated with the crawler.For ETL jobs that read example_table, grant Describe and Select permissions for example_table to the IAM role that's associated with the job. If the ETL job is updating example_table, then grant Alter permissions for example_table to the IAM role that's associated with the job.Open the Lake Formation console.In the navigation pane, under Permissions, choose Data lake permissions.Choose Grant.Under Principals, choose IAM users and roles.For IAM users and roles, choose the IAM role.Under LF-Tags or catalog resources, choose Named data catalog resources.For Databases, choose the database that your crawler is writing to.For Tables-optional, choose the table that your crawler is accessing.Under Table permissions, choose Select, Describe, or Alter based on your use case.If you want the IAM role to grant permissions to other roles in your account, then set permissions under Grantable permissions.Choose Grant.Access issues with Lake Formation IAM permissionsIf IAM permissions issues for Lake Formation are causing the error, then you get an error message similar to one of the following one:com.amazonaws.services.lakeformation.model.AccessDeniedException: Service Principal: glue.amazonaws.com is not authorized to perform: lakeformation:GetDataAccesson resource: s3://sample-bucket/sample-prefix/ because no identity-based policy allows the lakeformation:GetDataAccess actionYou get this error when the AWS Glue job role or AWS Glue crawler role doesn't have sufficient IAM permissions. The job or role must have permission to check if Lake Formation can vend temporary credentials to the role and the Amazon S3 location.Open the IAM console.Create an IAM policy for your AWS Glue crawler or AWS Glue job role.Add the permission lakeformation:GetDataAccess as the action for the resource in the policy. Note: The API lakeformation:GetDataAccess must use the wildcard as its resource.Attach the policy to your AWS Glue crawler or AWS Glue job role.Access issues with Amazon S3 pathIf Amazon S3 path issues are causing the error is caused, then the error message looks similar to the following one. The error includes the Amazon S3 path:Insufficient Lake Formation permission(s) on s3://s3-example-bucket/example-prefix/ (Database name: example-database, Table Name: example-table)<br>Insufficient Lake Formation permission(s) on s3://s3-example-bucket/example-prefix/This error occurs when the IAM role that's associated with the crawler or ETL job doesn't have the required permission to access the Amazon S3 path.To resolve this error, complete the following steps:Open the Lake Formation console.In the navigation pane, under Register and ingest, choose Data lake locations.Verify that the Amazon S3 path or prefix of the path from the error message is a registered location in the Data lake locations list.If the Amazon S3 path or prefix in the error message isn't listed in the Data lake locations list, then choose Register location.For Amazon S3 path, choose Browse, and then choose the correct Amazon S3 path.For IAM role, keep the default selection of AWSServiceRoleForLakeFormationDataAccess. If you use a custom IAM role, then be sure that the relevant requirements are met. Important: When registering an Amazon S3 location, Lake Formation assumes the preceding IAM role. This grants temporary credentials to integrated AWS services that access data in that location. Verify that the IAM role that's associated with the registered Amazon S3 location has the required permissions to read and write to the S3 bucket. This prevents the AccessDeniederror.In the navigation pane, under Permissions, choose Data locations.Choose Grant.For Grant permissions, choose My account.Under IAM users and roles, choose the IAM role that you want to grant access for.Choose Grant.

Related informationManaging Lake Formation permissionsRegistering an Amazon S3 location