Skip to content

Commit

Permalink
Setup state bucket for gcp training
Browse files Browse the repository at this point in the history
  • Loading branch information
koenighotze committed Feb 19, 2024
1 parent 4902429 commit 93f5009
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
30 changes: 15 additions & 15 deletions terraform-examples/terraform-state-bucket-admin-iam.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# # This SA needs to be able to do some privileged work
# #tfsec:ignore:google-iam-no-privileged-service-accounts
# #checkov:skip=CKV_GCP_117:Allow admin for this bucket
# resource "google_project_iam_binding" "project_iam_binding" {
# for_each = toset([
# "roles/storage.admin"
# ])
# project = data.google_project.project.project_id
# role = "roles/storage.admin"
# This SA needs to be able to do some privileged work
#tfsec:ignore:google-iam-no-privileged-service-accounts
#checkov:skip=CKV_GCP_117:Allow admin for this bucket
resource "google_project_iam_binding" "project_iam_binding" {
for_each = toset([
"roles/storage.admin"
])
project = data.google_project.project.project_id
role = "roles/storage.admin"

# #tfsec:ignore:google-iam-no-privileged-service-accounts
# members = [
# "serviceAccount:${google_service_account.sa.email}",
# "serviceAccount:${var.admin_sa_email}"
# ]
# }
#tfsec:ignore:google-iam-no-privileged-service-accounts
members = [
"serviceAccount:${google_service_account.sa.email}",
"serviceAccount:${var.admin_sa_email}"
]
}
36 changes: 18 additions & 18 deletions terraform-examples/terraform-state-bucket.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# resource "google_storage_bucket" "state_bucket" {
# #checkov:skip=CKV_GCP_62:Logging deactivated for now
# project = data.google_project.project.project_id
# name = "${data.google_project.project.project_id}-state"
# location = var.location
# uniform_bucket_level_access = true
# force_destroy = true
resource "google_storage_bucket" "state_bucket" {
#checkov:skip=CKV_GCP_62:Logging deactivated for now
project = data.google_project.project.project_id
name = "${data.google_project.project.project_id}-state"
location = var.location
uniform_bucket_level_access = true
force_destroy = true

# public_access_prevention = "enforced"
public_access_prevention = "enforced"

# versioning {
# #checkov:skip=CKV_GCP_78:We don't version states
# enabled = false
# }
# }
versioning {
#checkov:skip=CKV_GCP_78:We don't version states
enabled = false
}
}

# resource "google_storage_bucket_iam_member" "bucket_iam_member" {
# bucket = google_storage_bucket.state_bucket.name
# role = "roles/storage.admin"
# member = "serviceAccount:${google_service_account.sa.email}"
# }
resource "google_storage_bucket_iam_member" "bucket_iam_member" {
bucket = google_storage_bucket.state_bucket.name
role = "roles/storage.admin"
member = "serviceAccount:${google_service_account.sa.email}"
}

0 comments on commit 93f5009

Please sign in to comment.