Skip to content

How to grant LakeFormation permission to s3 tables data lake?

0

Currently I've managed only to assign LakeFormation database permissions via AWS console. However when I'm trying to set up CDK code it doesn't work:

const catalogId = `${this.account}:s3tablescatalog/${this.tableBucket.tableBucketName}`;
new aws_lakeformation.CfnPrincipalPermissions(
	this,
	`PrincipalPermission`,
	{
		permissions: ["ALL"],
		permissionsWithGrantOption: ["ALL"],
		principal: {
			dataL-akePrinc-ipalIdent-ifier: roleArn, // The minuses are because AWS Questions are blocking such content ....
		},
		resource: {
			database: {
				catalogId,
				name: this.namespace.namespaceName,
			},
		},
	},
);

With this code, I'm getting an error Properties validation failed for resource XXDataLa-kePrinc-ipalPerm-issionXX with message: [#/Resource/Database/CatalogId: expected maxLength: 12, actual: 63]. I'm using 2.206.0 aws-cdk-lib package.

The catalogID in AWS console can be selected as: {account}:s3tablescatalog/{tableBucketName}, however when done by AWS CDK, the AWS responds with the size that must be 12 = just account.

When I'm entering just the accountID, I'm getting a very valid error "Database not found.", as this database is in the different catalog.

When I'm trying to set just the CfnPermission, like so:

const catalogId = `${this.account}:s3tablescatalog/${this.tableBucket.tableBucketName}`;
new aws_lakeformation.CfnPermissions(this, `PrincipalPermission`, {
	permissions: ["ALL"],
	permissionsWithGrantOption: ["ALL"],
	dataLakePrincipal: {
		dataLak-ePrincipalIdentifier: roleArn,
	},
	resource: {
		databaseResource: {
			catalogId,
			name: this.namespace.namespaceName,
		},
	},
});

Then I'm getting an error: Insufficient Glue permissions to access database cloud_costs (Service: AWSLakeFormation; Status Code: 400; Error Code: AccessDeniedException; Even though I run the deployment with Standard-Admin SSO role.

How can I resolve it?

  • Hey, don't know if this will help but maybe the problem is using the Standard-Admin SSO role, as far as i remember the managed role by AWS was missing some lakeformation permissions, for example i have a role using that and wasn't able to enable the s3 analytics integrations with it. So cehck if you don't need to add some perms on top of the manager Admin role.

    Your second code snipped should work after having the permissions set up

asked a year ago1.8K views

3 Answers
0

We are currently achieving this with (Python), e.g. (in stack code)::

        lakeformation.CfnPermissions(
            self,
            f"{data_product_table_name}-lf-permissions-for-firehose",
            permissions=["ALL"],
            permissions_with_grant_option=[],
            data_lake_principal=lakeformation.CfnPermissions.___(
                data_lake_principal_identifier=<principal_arn>
            ),
            resource=lakeformation.CfnPermissions.ResourceProperty(
                table_resource=lakeformation.CfnPermissions.TableResourceProperty(
                    catalog_id=f"{Aws.ACCOUNT_ID}:s3tablescatalog/{iceberg_bucket_name}",
                    database_name={data_product_namespace_name},
                    name={data_product_table_name},
                )
            ),
        )

And it accepts it the catalog ID. Not all interfaces accommodate this yet. CfnPrincipalPermissions does not appear to, currently.

answered a year ago

  • "___" in my post is "Data Lake Principal Property" (no spaces). For some reason it wouldn't let me post it.

0

Hello,

The S3 Tables feature, which was announced as a new open table format for organizing data in Amazon S3, introduces a specialized catalog identifier format that differs from the traditional numeric account ID format that CDK Lake Formation constructs expect. When you attempt to reference an S3 Tables catalog in your CDK Lake Formation permissions, the CDK validation layer rejects the non-standard catalog ID format, resulting in the properties validation failure you're experiencing.

In standard Lake Formation implementations, the catalog ID parameter expects your 12-digit AWS account ID in numeric format. However, S3 Tables catalogs use a different identifier structure that the current CDK Lake Formation constructs cannot recognize or validate properly.

I recommend subscribing to the AWS CDK GitHub repository (1) to stay informed about new releases and feature announcements. Additionally, you can track the AWS What's New announcements (2) for updates on both S3 Tables and CDK feature releases.

Regarding, the Access Denied, when you put Catalog ID it will refer to the Database in AWS Glue Data Catalog or shared database through Lake Formation. As a result, if there is no database, then you would get 'Database not found' error.

References:

  1. AWS CDK GitHub Repository: https://github.com/aws/aws-cdk
  2. AWS What's New: https://aws.amazon.com/new/
AWS

answered a year ago

-1

To grant Lake Formation permissions to S3 Tables, you need to use the AWS CLI or Lake Formation console rather than trying to use CDK with CfnPrincipalPermissions. The issue you're encountering is because the S3 Tables catalog has a special format that the CDK construct doesn't currently support properly.

For S3 Tables, you need to grant permissions using the AWS CLI. Here's how to do it:

  1. Make sure you're running the commands as a data lake administrator.

  2. Use the following AWS CLI command to grant Lake Formation permissions on a table in an S3 table bucket:

aws lakeformation grant-permissions \
--region us-east-1 \
--cli-input-json \
'{
"Principal": {
"DataLakePrincipalIdentifier": "your-role-arn"
},
"Resource": {
"Table": {
"CatalogId": "account-id:s3tablescatalog/your-table-bucket-name",
"DatabaseName": "your-namespace-name",
"Name": "your-table-name"
}
},
"Permissions": [
"ALL"
]
}'

Alternatively, you can use the Lake Formation console:

  1. Navigate to the Lake Formation service in the AWS Management Console
  2. Select "Data permissions" > "Grant"
  3. In the Principals section, select the appropriate principal type and add your role ARN
  4. Select "Named Data Catalog Resources" and choose the S3 Tables catalog, database, and table
  5. Select the permissions you want to grant
  6. Click "Grant"

Since the CDK construct doesn't properly support the S3 Tables catalog format, you might need to handle this permission granting as a post-deployment step using custom resources or AWS CLI commands in your deployment pipeline.
Sources
Using Amazon S3 Tables with AWS analytics services - Amazon Simple Storage Service
Stream data from Amazon MSK to Apache Iceberg tables in Amazon S3 and Amazon S3 Tables using Amazon Data Firehose | AWS Big Data Blog

answered a year ago

  • This must be part of cloudformation stack. There's no and should not be any SDK calls involved.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.