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

yandex.IamServiceAccountIamPolicy

Explore with Pulumi AI

yandex logo
Yandex v0.13.0 published on Tuesday, Feb 22, 2022 by Pulumi

    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_policy

    import * as pulumi from "@pulumi/pulumi";
    import * as yandex from "@pulumi/yandex";
    
    const admin = pulumi.output(yandex.getIamPolicy({
        bindings: [{
            members: ["userAccount:foobar_user_id"],
            role: "admin",
        }],
    }));
    const admin_account_iam = new yandex.IamServiceAccountIamPolicy("admin-account-iam", {
        policyData: admin.policyData,
        serviceAccountId: "your-service-account-id",
    });
    
    import pulumi
    import pulumi_yandex as yandex
    
    admin = yandex.get_iam_policy(bindings=[yandex.GetIamPolicyBindingArgs(
        members=["userAccount:foobar_user_id"],
        role="admin",
    )])
    admin_account_iam = yandex.IamServiceAccountIamPolicy("admin-account-iam",
        policy_data=admin.policy_data,
        service_account_id="your-service-account-id")
    
    using Pulumi;
    using Yandex = Pulumi.Yandex;
    
    class MyStack : Stack
    {
        public MyStack()
        {
            var admin = Output.Create(Yandex.GetIamPolicy.InvokeAsync(new Yandex.GetIamPolicyArgs
            {
                Bindings = 
                {
                    new Yandex.Inputs.GetIamPolicyBindingArgs
                    {
                        Members = 
                        {
                            "userAccount:foobar_user_id",
                        },
                        Role = "admin",
                    },
                },
            }));
            var admin_account_iam = new Yandex.IamServiceAccountIamPolicy("admin-account-iam", new Yandex.IamServiceAccountIamPolicyArgs
            {
                PolicyData = admin.Apply(admin => admin.PolicyData),
                ServiceAccountId = "your-service-account-id",
            });
        }
    
    }
    
    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 {
    		admin, err := yandex.GetIamPolicy(ctx, &GetIamPolicyArgs{
    			Bindings: []GetIamPolicyBinding{
    				GetIamPolicyBinding{
    					Members: []string{
    						"userAccount:foobar_user_id",
    					},
    					Role: "admin",
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = yandex.NewIamServiceAccountIamPolicy(ctx, "admin-account-iam", &yandex.IamServiceAccountIamPolicyArgs{
    			PolicyData:       pulumi.String(admin.PolicyData),
    			ServiceAccountId: pulumi.String("your-service-account-id"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    

    Create IamServiceAccountIamPolicy Resource

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

    Constructor syntax

    new IamServiceAccountIamPolicy(name: string, args: IamServiceAccountIamPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def IamServiceAccountIamPolicy(resource_name: str,
                                   args: IamServiceAccountIamPolicyArgs,
                                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def IamServiceAccountIamPolicy(resource_name: str,
                                   opts: Optional[ResourceOptions] = None,
                                   policy_data: Optional[str] = None,
                                   service_account_id: Optional[str] = None)
    func NewIamServiceAccountIamPolicy(ctx *Context, name string, args IamServiceAccountIamPolicyArgs, opts ...ResourceOption) (*IamServiceAccountIamPolicy, error)
    public IamServiceAccountIamPolicy(string name, IamServiceAccountIamPolicyArgs args, CustomResourceOptions? opts = null)
    public IamServiceAccountIamPolicy(String name, IamServiceAccountIamPolicyArgs args)
    public IamServiceAccountIamPolicy(String name, IamServiceAccountIamPolicyArgs args, CustomResourceOptions options)
    
    type: yandex:IamServiceAccountIamPolicy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args IamServiceAccountIamPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args IamServiceAccountIamPolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args IamServiceAccountIamPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args IamServiceAccountIamPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args IamServiceAccountIamPolicyArgs
    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 iamServiceAccountIamPolicyResource = new Yandex.IamServiceAccountIamPolicy("iamServiceAccountIamPolicyResource", new()
    {
        PolicyData = "string",
        ServiceAccountId = "string",
    });
    
    example, err := yandex.NewIamServiceAccountIamPolicy(ctx, "iamServiceAccountIamPolicyResource", &yandex.IamServiceAccountIamPolicyArgs{
    	PolicyData:       pulumi.String("string"),
    	ServiceAccountId: pulumi.String("string"),
    })
    
    var iamServiceAccountIamPolicyResource = new IamServiceAccountIamPolicy("iamServiceAccountIamPolicyResource", IamServiceAccountIamPolicyArgs.builder()
        .policyData("string")
        .serviceAccountId("string")
        .build());
    
    iam_service_account_iam_policy_resource = yandex.IamServiceAccountIamPolicy("iamServiceAccountIamPolicyResource",
        policy_data="string",
        service_account_id="string")
    
    const iamServiceAccountIamPolicyResource = new yandex.IamServiceAccountIamPolicy("iamServiceAccountIamPolicyResource", {
        policyData: "string",
        serviceAccountId: "string",
    });
    
    type: yandex:IamServiceAccountIamPolicy
    properties:
        policyData: string
        serviceAccountId: string
    

    IamServiceAccountIamPolicy Resource Properties

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

    Inputs

    The IamServiceAccountIamPolicy resource accepts the following input properties:

    PolicyData string
    The policy data generated by a yandex.getIamPolicy data source.
    ServiceAccountId string
    The service account ID to apply a policy to.
    PolicyData string
    The policy data generated by a yandex.getIamPolicy data source.
    ServiceAccountId string
    The service account ID to apply a policy to.
    policyData String
    The policy data generated by a yandex.getIamPolicy data source.
    serviceAccountId String
    The service account ID to apply a policy to.
    policyData string
    The policy data generated by a yandex.getIamPolicy data source.
    serviceAccountId string
    The service account ID to apply a policy to.
    policy_data str
    The policy data generated by a yandex.getIamPolicy data source.
    service_account_id str
    The service account ID to apply a policy to.
    policyData String
    The policy data generated by a yandex.getIamPolicy data source.
    serviceAccountId String
    The service account ID to apply a policy to.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the IamServiceAccountIamPolicy 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 IamServiceAccountIamPolicy Resource

    Get an existing IamServiceAccountIamPolicy 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?: IamServiceAccountIamPolicyState, opts?: CustomResourceOptions): IamServiceAccountIamPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            policy_data: Optional[str] = None,
            service_account_id: Optional[str] = None) -> IamServiceAccountIamPolicy
    func GetIamServiceAccountIamPolicy(ctx *Context, name string, id IDInput, state *IamServiceAccountIamPolicyState, opts ...ResourceOption) (*IamServiceAccountIamPolicy, error)
    public static IamServiceAccountIamPolicy Get(string name, Input<string> id, IamServiceAccountIamPolicyState? state, CustomResourceOptions? opts = null)
    public static IamServiceAccountIamPolicy get(String name, Output<String> id, IamServiceAccountIamPolicyState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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:
    PolicyData string
    The policy data generated by a yandex.getIamPolicy data source.
    ServiceAccountId string
    The service account ID to apply a policy to.
    PolicyData string
    The policy data generated by a yandex.getIamPolicy data source.
    ServiceAccountId string
    The service account ID to apply a policy to.
    policyData String
    The policy data generated by a yandex.getIamPolicy data source.
    serviceAccountId String
    The service account ID to apply a policy to.
    policyData string
    The policy data generated by a yandex.getIamPolicy data source.
    serviceAccountId string
    The service account ID to apply a policy to.
    policy_data str
    The policy data generated by a yandex.getIamPolicy data source.
    service_account_id str
    The service account ID to apply a policy to.
    policyData String
    The policy data generated by a yandex.getIamPolicy data source.
    serviceAccountId String
    The service account ID to apply a policy to.

    Import

    Service account IAM policy resources can be imported using the service account ID.

     $ pulumi import yandex:index/iamServiceAccountIamPolicy:IamServiceAccountIamPolicy admin-account-iam service_account_id
    

    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.
    yandex logo
    Yandex v0.13.0 published on Tuesday, Feb 22, 2022 by Pulumi