Class CryptoKeyIAMPolicy
Three different resources help you manage your IAM policy for KMS crypto key. Each of these resources serves a different use case:
gcp.kms.CryptoKeyIAMPolicy: Authoritative. Sets the IAM policy for the crypto key and replaces any existing policy already attached.gcp.kms.CryptoKeyIAMBinding: 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 crypto key are preserved.gcp.kms.CryptoKeyIAMMember: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role for the crypto key are preserved.
Note:
gcp.kms.CryptoKeyIAMPolicycannot be used in conjunction withgcp.kms.CryptoKeyIAMBindingandgcp.kms.CryptoKeyIAMMemberor they will fight over what your policy should be.
Note:
gcp.kms.CryptoKeyIAMBindingresources can be used in conjunction withgcp.kms.CryptoKeyIAMMemberresources only if they do not grant privilege to the same role.
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 key = new Gcp.Kms.CryptoKey("key", new Gcp.Kms.CryptoKeyArgs
{
KeyRing = keyring.Id,
RotationPeriod = "100000s",
});
var admin = Output.Create(Gcp.Organizations.GetIAMPolicy.InvokeAsync(new Gcp.Organizations.GetIAMPolicyArgs
{
Binding =
{
{
{ "role", "roles/cloudkms.cryptoKeyEncrypter" },
{ "members",
{
"user:jane@example.com",
} },
},
},
}));
var cryptoKey = new Gcp.Kms.CryptoKeyIAMPolicy("cryptoKey", new Gcp.Kms.CryptoKeyIAMPolicyArgs
{
CryptoKeyId = key.Id,
PolicyData = admin.Apply(admin => admin.PolicyData),
});
}
}
With IAM Conditions:
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var admin = Output.Create(Gcp.Organizations.GetIAMPolicy.InvokeAsync(new Gcp.Organizations.GetIAMPolicyArgs
{
Bindings =
{
new Gcp.Organizations.Inputs.GetIAMPolicyBindingArgs
{
Condition = new Gcp.Organizations.Inputs.GetIAMPolicyBindingConditionArgs
{
Description = "Expiring at midnight of 2019-12-31",
Expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
Title = "expires_after_2019_12_31",
},
Members =
{
"user:jane@example.com",
},
Role = "roles/cloudkms.cryptoKeyEncrypter",
},
},
}));
}
}
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var cryptoKey = new Gcp.Kms.CryptoKeyIAMBinding("cryptoKey", new Gcp.Kms.CryptoKeyIAMBindingArgs
{
CryptoKeyId = google_kms_crypto_key.Key.Id,
Role = "roles/cloudkms.cryptoKeyEncrypter",
Members =
{
"user:jane@example.com",
},
});
}
}
With IAM Conditions:
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var cryptoKey = new Gcp.Kms.CryptoKeyIAMBinding("cryptoKey", new Gcp.Kms.CryptoKeyIAMBindingArgs
{
CryptoKeyId = google_kms_crypto_key.Key.Id,
Role = "roles/cloudkms.cryptoKeyEncrypter",
Members =
{
"user:jane@example.com",
},
Condition = new Gcp.Kms.Inputs.CryptoKeyIAMBindingConditionArgs
{
Title = "expires_after_2019_12_31",
Description = "Expiring at midnight of 2019-12-31",
Expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
},
});
}
}
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var cryptoKey = new Gcp.Kms.CryptoKeyIAMMember("cryptoKey", new Gcp.Kms.CryptoKeyIAMMemberArgs
{
CryptoKeyId = google_kms_crypto_key.Key.Id,
Role = "roles/cloudkms.cryptoKeyEncrypter",
Member = "user:jane@example.com",
});
}
}
With IAM Conditions:
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var cryptoKey = new Gcp.Kms.CryptoKeyIAMMember("cryptoKey", new Gcp.Kms.CryptoKeyIAMMemberArgs
{
CryptoKeyId = google_kms_crypto_key.Key.Id,
Role = "roles/cloudkms.cryptoKeyEncrypter",
Member = "user:jane@example.com",
Condition = new Gcp.Kms.Inputs.CryptoKeyIAMMemberConditionArgs
{
Title = "expires_after_2019_12_31",
Description = "Expiring at midnight of 2019-12-31",
Expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
},
});
}
}
Inherited Members
Namespace: Pulumi.Gcp.Kms
Assembly: Pulumi.Gcp.dll
Syntax
public class CryptoKeyIAMPolicy : CustomResource
Constructors
View SourceCryptoKeyIAMPolicy(String, CryptoKeyIAMPolicyArgs, CustomResourceOptions)
Create a CryptoKeyIAMPolicy resource with the given unique name, arguments, and options.
Declaration
public CryptoKeyIAMPolicy(string name, CryptoKeyIAMPolicyArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| CryptoKeyIAMPolicyArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceCryptoKeyId
The crypto key ID, in the form
{project_id}/{location_name}/{key_ring_name}/{crypto_key_name} or
{location_name}/{key_ring_name}/{crypto_key_name}. In the second form,
the provider's project setting will be used as a fallback.
Declaration
public Output<string> CryptoKeyId { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Etag
(Computed) The etag of the project's IAM policy.
Declaration
public Output<string> Etag { 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>, CryptoKeyIAMPolicyState, CustomResourceOptions)
Get an existing CryptoKeyIAMPolicy resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static CryptoKeyIAMPolicy Get(string name, Input<string> id, CryptoKeyIAMPolicyState 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. |
| CryptoKeyIAMPolicyState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| CryptoKeyIAMPolicy |