1. Packages
  2. Yandex
  3. API Docs
  4. IamServiceAccountIamBinding
Yandex v0.13.0 published on Tuesday, Feb 22, 2022 by Pulumi

yandex.IamServiceAccountIamBinding

Explore with Pulumi AI

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_iam_service_account_iam_policy: Authoritative. Sets the IAM policy for the service account and replaces any existing policy already attached.
  • yandex_iam_service_account_iam_binding: Authoritative for a given role. Updates the IAM policy to grant a role to a list of members. Other roles within the IAM policy for the service account are preserved.
  • yandex_iam_service_account_iam_member: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role of the service account are preserved.

Note: yandex.IamServiceAccountIamPolicy cannot be used in conjunction with yandex.IamServiceAccountIamBinding and yandex.IamServiceAccountIamMember or they will conflict over what your policy should be.

Note: yandex.IamServiceAccountIamBinding resources can be used in conjunction with yandex.IamServiceAccountIamMember resources only if they do not grant privileges to the same role.

yandex_service_account_iam_binding

import * as pulumi from "@pulumi/pulumi";
import * as yandex from "@pulumi/yandex";

const admin_account_iam = new yandex.IamServiceAccountIamBinding("admin-account-iam", {
    members: ["userAccount:foo_user_id"],
    role: "admin",
    serviceAccountId: "your-service-account-id",
});
Copy
import pulumi
import pulumi_yandex as yandex

admin_account_iam = yandex.IamServiceAccountIamBinding("admin-account-iam",
    members=["userAccount:foo_user_id"],
    role="admin",
    service_account_id="your-service-account-id")
Copy
using Pulumi;
using Yandex = Pulumi.Yandex;

class MyStack : Stack
{
    public MyStack()
    {
        var admin_account_iam = new Yandex.IamServiceAccountIamBinding("admin-account-iam", new Yandex.IamServiceAccountIamBindingArgs
        {
            Members = 
            {
                "userAccount:foo_user_id",
            },
            Role = "admin",
            ServiceAccountId = "your-service-account-id",
        });
    }

}
Copy
package main

import (
	"github.com/pulumi/pulumi-yandex/sdk/go/yandex"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := yandex.NewIamServiceAccountIamBinding(ctx, "admin-account-iam", &yandex.IamServiceAccountIamBindingArgs{
			Members: pulumi.StringArray{
				pulumi.String("userAccount:foo_user_id"),
			},
			Role:             pulumi.String("admin"),
			ServiceAccountId: pulumi.String("your-service-account-id"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy

Create IamServiceAccountIamBinding Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new IamServiceAccountIamBinding(name: string, args: IamServiceAccountIamBindingArgs, opts?: CustomResourceOptions);
@overload
def IamServiceAccountIamBinding(resource_name: str,
                                args: IamServiceAccountIamBindingArgs,
                                opts: Optional[ResourceOptions] = None)

@overload
def IamServiceAccountIamBinding(resource_name: str,
                                opts: Optional[ResourceOptions] = None,
                                members: Optional[Sequence[str]] = None,
                                role: Optional[str] = None,
                                service_account_id: Optional[str] = None,
                                sleep_after: Optional[int] = None)
func NewIamServiceAccountIamBinding(ctx *Context, name string, args IamServiceAccountIamBindingArgs, opts ...ResourceOption) (*IamServiceAccountIamBinding, error)
public IamServiceAccountIamBinding(string name, IamServiceAccountIamBindingArgs args, CustomResourceOptions? opts = null)
public IamServiceAccountIamBinding(String name, IamServiceAccountIamBindingArgs args)
public IamServiceAccountIamBinding(String name, IamServiceAccountIamBindingArgs args, CustomResourceOptions options)
type: yandex:IamServiceAccountIamBinding
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. IamServiceAccountIamBindingArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. IamServiceAccountIamBindingArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. IamServiceAccountIamBindingArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. IamServiceAccountIamBindingArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. IamServiceAccountIamBindingArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var iamServiceAccountIamBindingResource = new Yandex.IamServiceAccountIamBinding("iamServiceAccountIamBindingResource", new()
{
    Members = new[]
    {
        "string",
    },
    Role = "string",
    ServiceAccountId = "string",
    SleepAfter = 0,
});
Copy
example, err := yandex.NewIamServiceAccountIamBinding(ctx, "iamServiceAccountIamBindingResource", &yandex.IamServiceAccountIamBindingArgs{
	Members: pulumi.StringArray{
		pulumi.String("string"),
	},
	Role:             pulumi.String("string"),
	ServiceAccountId: pulumi.String("string"),
	SleepAfter:       pulumi.Int(0),
})
Copy
var iamServiceAccountIamBindingResource = new IamServiceAccountIamBinding("iamServiceAccountIamBindingResource", IamServiceAccountIamBindingArgs.builder()
    .members("string")
    .role("string")
    .serviceAccountId("string")
    .sleepAfter(0)
    .build());
Copy
iam_service_account_iam_binding_resource = yandex.IamServiceAccountIamBinding("iamServiceAccountIamBindingResource",
    members=["string"],
    role="string",
    service_account_id="string",
    sleep_after=0)
Copy
const iamServiceAccountIamBindingResource = new yandex.IamServiceAccountIamBinding("iamServiceAccountIamBindingResource", {
    members: ["string"],
    role: "string",
    serviceAccountId: "string",
    sleepAfter: 0,
});
Copy
type: yandex:IamServiceAccountIamBinding
properties:
    members:
        - string
    role: string
    serviceAccountId: string
    sleepAfter: 0
Copy

IamServiceAccountIamBinding Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The IamServiceAccountIamBinding resource accepts the following input properties:

Members This property is required. List<string>
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.
Role This property is required. string
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
ServiceAccountId This property is required. string
The service account ID to apply a binding to.
SleepAfter int
Members This property is required. []string
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.
Role This property is required. string
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
ServiceAccountId This property is required. string
The service account ID to apply a binding to.
SleepAfter int
members This property is required. List<String>
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.
role This property is required. String
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
serviceAccountId This property is required. String
The service account ID to apply a binding to.
sleepAfter Integer
members This property is required. string[]
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.
role This property is required. string
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
serviceAccountId This property is required. string
The service account ID to apply a binding to.
sleepAfter number
members This property is required. Sequence[str]
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.
role This property is required. str
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
service_account_id This property is required. str
The service account ID to apply a binding to.
sleep_after int
members This property is required. List<String>
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.
role This property is required. String
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
serviceAccountId This property is required. String
The service account ID to apply a binding to.
sleepAfter Number

Outputs

All input properties are implicitly available as output properties. Additionally, the IamServiceAccountIamBinding resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing IamServiceAccountIamBinding Resource

Get an existing IamServiceAccountIamBinding resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: IamServiceAccountIamBindingState, opts?: CustomResourceOptions): IamServiceAccountIamBinding
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        members: Optional[Sequence[str]] = None,
        role: Optional[str] = None,
        service_account_id: Optional[str] = None,
        sleep_after: Optional[int] = None) -> IamServiceAccountIamBinding
func GetIamServiceAccountIamBinding(ctx *Context, name string, id IDInput, state *IamServiceAccountIamBindingState, opts ...ResourceOption) (*IamServiceAccountIamBinding, error)
public static IamServiceAccountIamBinding Get(string name, Input<string> id, IamServiceAccountIamBindingState? state, CustomResourceOptions? opts = null)
public static IamServiceAccountIamBinding get(String name, Output<String> id, IamServiceAccountIamBindingState state, CustomResourceOptions options)
resources:  _:    type: yandex:IamServiceAccountIamBinding    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Members List<string>
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.
Role string
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
ServiceAccountId string
The service account ID to apply a binding to.
SleepAfter int
Members []string
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.
Role string
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
ServiceAccountId string
The service account ID to apply a binding to.
SleepAfter int
members List<String>
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.
role String
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
serviceAccountId String
The service account ID to apply a binding to.
sleepAfter Integer
members string[]
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.
role string
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
serviceAccountId string
The service account ID to apply a binding to.
sleepAfter number
members Sequence[str]
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.
role str
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
service_account_id str
The service account ID to apply a binding to.
sleep_after int
members List<String>
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.
role String
The role that should be applied. Only one yandex.IamServiceAccountIamBinding can be used per role.
serviceAccountId String
The service account ID to apply a binding to.
sleepAfter Number

Import

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

 $ pulumi import yandex:index/iamServiceAccountIamBinding:IamServiceAccountIamBinding admin-account-iam "service_account_id roles/editor"
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Yandex pulumi/pulumi-yandex
License
Apache-2.0
Notes
This Pulumi package is based on the yandex Terraform Provider.