Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected TF file #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions data-proc-nat-gateway.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ resource "yandex_vpc_security_group" "data-proc-security-group" {
}

ingress {
description = "Allow any traffic within the security group"
description = "Allow any incoming traffic within the security group"
protocol = "ANY"
from_port = 0
to_port = 65535
predefined_target = "self_security_group"
}

egress {
description = "Allow any traffic within the security group"
description = "Allow any outgoing traffic within the security group"
protocol = "ANY"
from_port = 0
to_port = 65535
Expand All @@ -77,17 +77,23 @@ resource "yandex_vpc_security_group" "data-proc-security-group" {
}
}

# Create a service account
# Create a service account for Data Processing cluster
resource "yandex_iam_service_account" "dataproc-sa" {
folder_id = local.folder_id
name = "data-proc-sa"
}

# Create a service account for S3 Bucket
resource "yandex_iam_service_account" "bucket-sa" {
folder_id = local.folder_id
name = "bucket-sa"
}

# Grant permissions to the service account
resource "yandex_resourcemanager_folder_iam_member" "sa-editor" {
resource "yandex_resourcemanager_folder_iam_member" "sa-admin" {
folder_id = local.folder_id
role = "storage.editor"
member = "serviceAccount:${yandex_iam_service_account.dataproc-sa.id}"
role = "storage.admin"
member = "serviceAccount:${yandex_iam_service_account.bucket-sa.id}"
}

resource "yandex_resourcemanager_folder_iam_member" "dataproc-sa-role-dataproc-agent" {
Expand All @@ -104,11 +110,21 @@ resource "yandex_resourcemanager_folder_iam_member" "dataproc-sa-role-dataproc-p

resource "yandex_iam_service_account_static_access_key" "sa-static-key" {
description = "Static access key for Object Storage"
service_account_id = yandex_iam_service_account.dataproc-sa.id
service_account_id = yandex_iam_service_account.bucket-sa.id
}

# Use keys to create a bucket
resource "yandex_storage_bucket" "obj-storage-bucket" {
depends_on = [
yandex_resourcemanager_folder_iam_member.sa-admin
]

grant {
id = yandex_iam_service_account.dataproc-sa.id
type = "CanonicalUser"
permissions = ["READ","WRITE"]
}

access_key = yandex_iam_service_account_static_access_key.sa-static-key.access_key
secret_key = yandex_iam_service_account_static_access_key.sa-static-key.secret_key
bucket = local.bucket
Expand All @@ -125,11 +141,16 @@ resource "yandex_dataproc_cluster" "dataproc-cluster" {
yandex_vpc_security_group.data-proc-security-group.id
]

depends_on = [
yandex_resourcemanager_folder_iam_member.dataproc-sa-role-dataproc-provisioner,
yandex_resourcemanager_folder_iam_member.dataproc-sa-role-dataproc-agent
]

cluster_config {
hadoop {
services = ["HDFS", "YARN", "SPARK", "TEZ", "MAPREDUCE", "HIVE"]
ssh_public_keys = [
file(local.path_to_ssh_public_key)
"${file(local.path_to_ssh_public_key)}"
]
}

Expand Down