» IAM policy for a service account

When managing IAM roles, you can treat a service account either as a resource or as an identity. This resource is used to add IAM policy bindings to a service account resource to configure permissions that define who can edit the service account.

There are three different resources that help you manage your IAM policy for a service account. Each of these resources is used for a different use case:

» yandex_service_account_iam_binding

resource "yandex_iam_service_account_iam_binding" "admin-account-iam" {
  service_account_id = "your-service-account-id"
  role               = "admin"

  members = [
    "userAccount:foo_user_id",
  ]
}

» Argument Reference

The following arguments are supported:

  • service_account_id - (Required) The service account ID to apply a binding to.

  • role - (Required) The role that should be applied. Only one yandex_iam_service_account_iam_binding can be used per role.

  • members - (Required) Identities that will be granted the privilege in role. Each entry can have one of the following values:

    • userAccount:{user_id}: A unique user ID that represents a specific Yandex account.
    • serviceAccount:{service_account_id}: A unique service account ID.

» Import

Service account IAM binding resources can be imported using the service account ID and role.

$ terraform import yandex_iam_service_account_iam_binding.admin-account-iam "service_account_id roles/editor"