-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws-iam-snowflake-setup.tf
65 lines (61 loc) · 1.62 KB
/
aws-iam-snowflake-setup.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Snowflake Role and Policy
resource "aws_iam_role" "snowflake_role" {
name = "snowflake_role"
assume_role_policy = jsonencode({
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Principal": {
"AWS": snowflake_storage_integration.aws_s3_integration.storage_aws_iam_user_arn
}
"Condition" : {
"StringEquals" : {
"sts:ExternalId" : snowflake_storage_integration.aws_s3_integration.storage_aws_external_id
}
}
}
]
})
}
resource "aws_iam_policy" "snowflake_s3_access_policy" {
name = "SnowflakeS3AccessPolicy"
policy = jsonencode({
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:GetObjectVersion",
"s3:DeleteObject",
"s3:DeleteObjectVersion"
],
"Resource": [
"${aws_s3_bucket.iceberg_bucket.arn}/warehouse/*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": aws_s3_bucket.iceberg_bucket.arn,
"Condition": {
"StringLike": {
"s3:prefix": [
"*"
]
}
}
}
]
})
}
resource "aws_iam_role_policy_attachment" "snowflake_policy_attachment" {
role = aws_iam_role.snowflake_role.name
policy_arn = aws_iam_policy.snowflake_s3_access_policy.arn
}