Class KeyRingIAMPolicy
Three different resources help you manage your IAM policy for KMS key ring. Each of these resources serves a different use case:
gcp.kms.KeyRingIAMPolicy: Authoritative. Sets the IAM policy for the key ring and replaces any existing policy already attached.gcp.kms.KeyRingIAMBinding: 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 key ring are preserved.gcp.kms.KeyRingIAMMember: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role for the key ring are preserved.
Note:
gcp.kms.KeyRingIAMPolicycannot be used in conjunction withgcp.kms.KeyRingIAMBindingandgcp.kms.KeyRingIAMMemberor they will fight over what your policy should be.
Note:
gcp.kms.KeyRingIAMBindingresources can be used in conjunction withgcp.kms.KeyRingIAMMemberresources only if they do not grant privilege to the same role.
google_kms_key_ring_iam_policy
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var keyring = new Gcp.Kms.KeyRing("keyring", new Gcp.Kms.KeyRingArgs
{
Location = "global",
});
var admin = Output.Create(Gcp.Organizations.GetIAMPolicy.InvokeAsync(new Gcp.Organizations.GetIAMPolicyArgs
{
Binding =
{
{
{ "role", "roles/editor" },
{ "members",
{
"user:jane@example.com",
} },
},
},
}));
var keyRing = new Gcp.Kms.KeyRingIAMPolicy("keyRing", new Gcp.Kms.KeyRingIAMPolicyArgs
{
KeyRingId = keyring.Id,
PolicyData = admin.Apply(admin => admin.PolicyData),
});
}
}
With IAM Conditions:
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var keyring = new Gcp.Kms.KeyRing("keyring", new Gcp.Kms.KeyRingArgs
{
Location = "global",
});
var admin = Output.Create(Gcp.Organizations.GetIAMPolicy.InvokeAsync(new Gcp.Organizations.GetIAMPolicyArgs
{
Binding =
{
{
{ "role", "roles/editor" },
{ "members",
{
"user:jane@example.com",
} },
{ "condition",
{
{ "title", "expires_after_2019_12_31" },
{ "description", "Expiring at midnight of 2019-12-31" },
{ "expression", "request.time < timestamp(\"2020-01-01T00:00:00Z\")" },
} },
},
},
}));
var keyRing = new Gcp.Kms.KeyRingIAMPolicy("keyRing", new Gcp.Kms.KeyRingIAMPolicyArgs
{
KeyRingId = keyring.Id,
PolicyData = admin.Apply(admin => admin.PolicyData),
});
}
}
google_kms_key_ring_iam_binding
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var keyRing = new Gcp.Kms.KeyRingIAMBinding("keyRing", new Gcp.Kms.KeyRingIAMBindingArgs
{
KeyRingId = "your-key-ring-id",
Members =
{
"user:jane@example.com",
},
Role = "roles/editor",
});
}
}
With IAM Conditions:
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var keyRing = new Gcp.Kms.KeyRingIAMBinding("keyRing", new Gcp.Kms.KeyRingIAMBindingArgs
{
Condition = new Gcp.Kms.Inputs.KeyRingIAMBindingConditionArgs
{
Description = "Expiring at midnight of 2019-12-31",
Expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
Title = "expires_after_2019_12_31",
},
KeyRingId = "your-key-ring-id",
Members =
{
"user:jane@example.com",
},
Role = "roles/editor",
});
}
}
google_kms_key_ring_iam_member
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var keyRing = new Gcp.Kms.KeyRingIAMMember("keyRing", new Gcp.Kms.KeyRingIAMMemberArgs
{
KeyRingId = "your-key-ring-id",
Member = "user:jane@example.com",
Role = "roles/editor",
});
}
}
With IAM Conditions:
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var keyRing = new Gcp.Kms.KeyRingIAMMember("keyRing", new Gcp.Kms.KeyRingIAMMemberArgs
{
Condition = new Gcp.Kms.Inputs.KeyRingIAMMemberConditionArgs
{
Description = "Expiring at midnight of 2019-12-31",
Expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
Title = "expires_after_2019_12_31",
},
KeyRingId = "your-key-ring-id",
Member = "user:jane@example.com",
Role = "roles/editor",
});
}
}
Inherited Members
Namespace: Pulumi.Gcp.Kms
Assembly: Pulumi.Gcp.dll
Syntax
public class KeyRingIAMPolicy : CustomResource
Constructors
View SourceKeyRingIAMPolicy(String, KeyRingIAMPolicyArgs, CustomResourceOptions)
Create a KeyRingIAMPolicy resource with the given unique name, arguments, and options.
Declaration
public KeyRingIAMPolicy(string name, KeyRingIAMPolicyArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| KeyRingIAMPolicyArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceEtag
(Computed) The etag of the key ring's IAM policy.
Declaration
public Output<string> Etag { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
KeyRingId
The key ring ID, in the form
{project_id}/{location_name}/{key_ring_name} or
{location_name}/{key_ring_name}. In the second form, the provider's
project setting will be used as a fallback.
Declaration
public Output<string> KeyRingId { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
PolicyData
The policy data generated by
a gcp.organizations.getIAMPolicy data source.
Declaration
public Output<string> PolicyData { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Methods
View SourceGet(String, Input<String>, KeyRingIAMPolicyState, CustomResourceOptions)
Get an existing KeyRingIAMPolicy resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static KeyRingIAMPolicy Get(string name, Input<string> id, KeyRingIAMPolicyState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| KeyRingIAMPolicyState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| KeyRingIAMPolicy |