1+ data "aws_caller_identity" "current" {}
2+ locals {
3+ s3_tables_resource = distinct ([for item in var . s3_tables : endswith (item, " /*" ) ? " ${ item } " : " ${ item } /*" ])
4+ tag_set = merge ({ Vendor = " StreamNative" , Module = " StreamNative S3 Table Access" , SNVersion = var.sn_policy_version }, var. tags )
5+ }
6+
7+ # #####
8+ # -- Create the IAM role inline policy for the the StreamNative Cloud access to s3 table
9+ # #####
10+ resource "aws_iam_role_policy" "s3_access_policy" {
11+ name = " ${ var . role } -s3-table"
12+ role = var. role
13+ policy = jsonencode ({
14+ " Version" : " 2012-10-17" ,
15+ " Statement" : [
16+ {
17+ " Sid" : " LakeFormationPermissionsForS3ListTableBucket" ,
18+ " Effect" : " Allow" ,
19+ " Action" : [
20+ " s3tables:ListTableBuckets"
21+ ],
22+ " Resource" : [
23+ " *"
24+ ]
25+ },
26+ {
27+ " Sid" : " LakeFormationDataAccessPermissionsForS3TableBucket" ,
28+ " Effect" : " Allow" ,
29+ " Action" : [
30+ " s3tables:CreateTableBucket" ,
31+ " s3tables:GetTableBucket" ,
32+ " s3tables:CreateNamespace" ,
33+ " s3tables:GetNamespace" ,
34+ " s3tables:ListNamespaces" ,
35+ " s3tables:DeleteNamespace" ,
36+ " s3tables:DeleteTableBucket" ,
37+ " s3tables:CreateTable" ,
38+ " s3tables:DeleteTable" ,
39+ " s3tables:GetTable" ,
40+ " s3tables:ListTables" ,
41+ " s3tables:RenameTable" ,
42+ " s3tables:UpdateTableMetadataLocation" ,
43+ " s3tables:GetTableMetadataLocation" ,
44+ " s3tables:GetTableData" ,
45+ " s3tables:PutTableData"
46+ ],
47+ " Resource" : local.s3_tables_resource
48+ }
49+ ]
50+ })
51+ }
0 commit comments