-
-
Save svenlito/0983a20d89f8441f4bf1be508de71d5a to your computer and use it in GitHub Desktop.
Terraform Set up for AWS Glue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create an IAM role | |
resource "aws_iam_role" "glue" { | |
name = "AWSGlueServiceRoleDefault" | |
assume_role_policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": "sts:AssumeRole", | |
"Principal": { | |
"Service": "glue.amazonaws.com" | |
}, | |
"Effect": "Allow", | |
"Sid": "" | |
} | |
] | |
} | |
EOF | |
} | |
# Create an IAM role policy attachment | |
resource "aws_iam_policy_attachment" "glue_service" { | |
name = "glue_service" | |
roles = ["${aws_iam_role.glue.name}"] | |
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSGlueServiceRole" | |
} | |
# Create iam policy | |
resource "aws_iam_role_policy" "my_s3_policy" { | |
name = "my_s3_policy" | |
role = aws_iam_role.glue.id | |
policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ | |
"s3:*" | |
], | |
"Effect": "Allow", | |
"Resource": [ | |
"arn:aws:s3:::jeph-raw-data-bucket/", | |
"arn:aws:s3:::jeph-raw-data-bucket/*" | |
] | |
} | |
] | |
} | |
EOF | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment