00-sa-and-bucket.tf 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #random
  2. resource "random_string" "random" {
  3. length = 4
  4. special = false
  5. upper = false
  6. }
  7. #------
  8. # Create SA for read/write yds
  9. resource "yandex_iam_service_account" "sa-writer-to-yds" {
  10. folder_id = var.folder_id
  11. name = "sa-for-writing-k8s-for-export"
  12. }
  13. # Grant permissions send logs to bucket
  14. resource "yandex_resourcemanager_folder_iam_member" "upload_logs" {
  15. depends_on = [yandex_iam_service_account.sa-writer-to-yds]
  16. folder_id = var.folder_id
  17. role = "yds.writer"
  18. member = "serviceAccount:${yandex_iam_service_account.sa-writer-to-yds.id}"
  19. }
  20. # Grant permissions invoke
  21. resource "yandex_resourcemanager_folder_iam_member" "upload_logs2" {
  22. depends_on = [yandex_iam_service_account.sa-writer-to-yds]
  23. folder_id = var.folder_id
  24. role = "serverless.functions.invoker"
  25. member = "serviceAccount:${yandex_iam_service_account.sa-writer-to-yds.id}"
  26. }
  27. # Create Static Access Keys
  28. resource "yandex_iam_service_account_static_access_key" "sa-writer-to-yds-keys" {
  29. depends_on = [yandex_iam_service_account.sa-writer-to-yds]
  30. service_account_id = yandex_iam_service_account.sa-writer-to-yds.id
  31. description = "Static access/secret keys for SA"
  32. }