Skip to content

Instantly share code, notes, and snippets.

@jehptes
Last active December 14, 2020 12:53
Show Gist options
  • Save jehptes/86d2d77bea623f90e0035463702d9f48 to your computer and use it in GitHub Desktop.
Save jehptes/86d2d77bea623f90e0035463702d9f48 to your computer and use it in GitHub Desktop.
Terraform Set up for AWS Glue
# 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