Grant access to S3

Is it possible to grant access to an S3 bucket for Quicksight via an API call or the AWS CDK?
I am doing it acutally manually on the console (https://eu-west-1.quicksight.aws.amazon.com/sn/console/resources) but need to include this action into a cloudformation stack.

I’m pretty sure that would be a policy attached to the S3 bucket.

https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/put-bucket-policy.html

Here is an example. You would need to figure out the iam role but I think this would work.

{
“Version”: “2012-10-17”,
“Id”: “BucketPolicy”,
“Statement”: [
{
“Effect”: “Allow”,
“Principal”: {
“AWS”: “arn:aws:iam:::role/service-role/aws-quicksight-service-role-v0”
},
“Action”: [
“s3:ListBucket”,
“s3:GetObject”,
“s3:GetObjectVersion”
],
“Resource”: [
“arn:aws:s3:::bucket”,
“arn:aws:s3:::bucket/*”
]
}
]
}