- Newest
- Most votes
- Most comments
There are a few issues with your approach:
-
Policy Type Mismatch: The policy you've created is a table bucket policy, but you're trying to apply it as a table policy. These are two different types of policies in S3 Tables.
-
Command Mismatch: You're using the
put-table-policycommand, which is for setting policies on individual tables. However, your policy is structured for a table bucket. -
Resource ARN: The resource ARN in your policy is for a table bucket, not an individual table.
To resolve this, you have two options:
Option 1: If you want to apply this policy to the entire table bucket:
Use the put-table-bucket-policy command instead. Modify your command to:
aws s3tables put-table-bucket-policy --table-bucket-arn arn:aws:s3tables:us-west-2:123:bucket/tabletest --resource-policy file://j.json --profile admin
Option 2: If you want to apply a policy to a specific table: Modify your policy to target a specific table instead of the entire bucket. Change the Resource line to:
"Resource": "arn:aws:s3tables:us-west-2:123:table/tabletest/namesptest/table1"
Then use your original put-table-policy command.
Also, ensure that:
- Your JSON file is properly formatted and doesn't contain any syntax errors.
- You have the necessary permissions to perform these operations.
- The role ARN, account ID, and other details in your policy are correct.
Remember, table bucket policies are for managing permissions at the bucket or namespace level, while table policies are for individual tables. Choose the appropriate policy type based on your access control needs.
Sources
Resource-based policies for S3 Tables - Amazon Simple Storage Service
Managing table bucket policies - Amazon Simple Storage Service
Managing table policies - Amazon Simple Storage Service
Hello.
I have a problem with the AWS CLI command I'm running.
If the policy is saved in a JSON file, please read it using "file://" as shown below.
aws s3tables put-table-policy --namespace my_namespace --name my_table --resource-policy file://Untitled-4.json --table-bucket-arn arn:aws:s3tables:ap-northeast-1:123456789012:bucket/kobayashi-test-table
By the way, there is no key called "s3tables:TableNamespace" in the "Condition" section of the policy you created, so I think it is invalid as a policy.
So please change it to "s3tables:namespace" as shown below.
In the "Condition" section of "s3tables", you can use "s3tables:namespace" and "s3tables:tableName".
https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3tables.html#amazons3tables-policy-keys
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789012:role/aws-reserved/sso.amazonaws.com/AWSReservedSSO_AdministratorAccess_yyyyy"
},
"Action": [
"s3tables:GetTableData",
"s3tables:GetTableMetadataLocation"
],
"Resource": "arn:aws:s3tables:ap-northeast-1:123456789012:bucket/kobayashi-test-table/table/12345678-1234-1234-1234-1233456578909",
"Condition": {
"StringLike": { "s3tables:namespace": "my_namespace" }
}
}
]
}
Relevant content
asked 3 years ago
asked a year ago
asked 3 years ago

I got the same error when i set this
aws s3tables put-table-bucket-policy --resource-policy ".\j.json" --table-bucket-arn arn:aws:s3tables:us-west-2:123:bucket/tabletest --profile adminAn error occurred (BadRequestException) when calling the PutTableBucketPolicy operation: The specified policy is malformed