github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/kms/grant.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package kms 5 6 import ( 7 "context" 8 "reflect" 9 10 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides a resource-based access control mechanism for a KMS customer master key. 16 // 17 // ## Import 18 // 19 // Using `pulumi import`, import KMS Grants using the Key ID and Grant ID separated by a colon (`:`). For example: 20 // 21 // ```sh 22 // $ pulumi import aws:kms/grant:Grant test 1234abcd-12ab-34cd-56ef-1234567890ab:abcde1237f76e4ba7987489ac329fbfba6ad343d6f7075dbd1ef191f0120514 23 // ``` 24 type Grant struct { 25 pulumi.CustomResourceState 26 27 // A structure that you can use to allow certain operations in the grant only when the desired encryption context is present. For more information about encryption context, see [Encryption Context](http://docs.aws.amazon.com/kms/latest/developerguide/encryption-context.html). 28 Constraints GrantConstraintArrayOutput `pulumi:"constraints"` 29 // A list of grant tokens to be used when creating the grant. See [Grant Tokens](http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token) for more information about grant tokens. 30 GrantCreationTokens pulumi.StringArrayOutput `pulumi:"grantCreationTokens"` 31 // The unique identifier for the grant. 32 GrantId pulumi.StringOutput `pulumi:"grantId"` 33 // The grant token for the created grant. For more information, see [Grant Tokens](http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token). 34 GrantToken pulumi.StringOutput `pulumi:"grantToken"` 35 // The principal that is given permission to perform the operations that the grant permits in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 36 GranteePrincipal pulumi.StringOutput `pulumi:"granteePrincipal"` 37 // The unique identifier for the customer master key (CMK) that the grant applies to. Specify the key ID or the Amazon Resource Name (ARN) of the CMK. To specify a CMK in a different AWS account, you must use the key ARN. 38 KeyId pulumi.StringOutput `pulumi:"keyId"` 39 // A friendly name for identifying the grant. 40 Name pulumi.StringOutput `pulumi:"name"` 41 // A list of operations that the grant permits. The permitted values are: `Decrypt`, `Encrypt`, `GenerateDataKey`, `GenerateDataKeyWithoutPlaintext`, `ReEncryptFrom`, `ReEncryptTo`, `Sign`, `Verify`, `GetPublicKey`, `CreateGrant`, `RetireGrant`, `DescribeKey`, `GenerateDataKeyPair`, or `GenerateDataKeyPairWithoutPlaintext`. 42 Operations pulumi.StringArrayOutput `pulumi:"operations"` 43 // If set to false (the default) the grants will be revoked upon deletion, and if set to true the grants will try to be retired upon deletion. Note that retiring grants requires special permissions, hence why we default to revoking grants. 44 // See [RetireGrant](https://docs.aws.amazon.com/kms/latest/APIReference/API_RetireGrant.html) for more information. 45 RetireOnDelete pulumi.BoolPtrOutput `pulumi:"retireOnDelete"` 46 // The principal that is given permission to retire the grant by using RetireGrant operation in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 47 RetiringPrincipal pulumi.StringPtrOutput `pulumi:"retiringPrincipal"` 48 } 49 50 // NewGrant registers a new resource with the given unique name, arguments, and options. 51 func NewGrant(ctx *pulumi.Context, 52 name string, args *GrantArgs, opts ...pulumi.ResourceOption) (*Grant, error) { 53 if args == nil { 54 return nil, errors.New("missing one or more required arguments") 55 } 56 57 if args.GranteePrincipal == nil { 58 return nil, errors.New("invalid value for required argument 'GranteePrincipal'") 59 } 60 if args.KeyId == nil { 61 return nil, errors.New("invalid value for required argument 'KeyId'") 62 } 63 if args.Operations == nil { 64 return nil, errors.New("invalid value for required argument 'Operations'") 65 } 66 opts = internal.PkgResourceDefaultOpts(opts) 67 var resource Grant 68 err := ctx.RegisterResource("aws:kms/grant:Grant", name, args, &resource, opts...) 69 if err != nil { 70 return nil, err 71 } 72 return &resource, nil 73 } 74 75 // GetGrant gets an existing Grant resource's state with the given name, ID, and optional 76 // state properties that are used to uniquely qualify the lookup (nil if not required). 77 func GetGrant(ctx *pulumi.Context, 78 name string, id pulumi.IDInput, state *GrantState, opts ...pulumi.ResourceOption) (*Grant, error) { 79 var resource Grant 80 err := ctx.ReadResource("aws:kms/grant:Grant", name, id, state, &resource, opts...) 81 if err != nil { 82 return nil, err 83 } 84 return &resource, nil 85 } 86 87 // Input properties used for looking up and filtering Grant resources. 88 type grantState struct { 89 // A structure that you can use to allow certain operations in the grant only when the desired encryption context is present. For more information about encryption context, see [Encryption Context](http://docs.aws.amazon.com/kms/latest/developerguide/encryption-context.html). 90 Constraints []GrantConstraint `pulumi:"constraints"` 91 // A list of grant tokens to be used when creating the grant. See [Grant Tokens](http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token) for more information about grant tokens. 92 GrantCreationTokens []string `pulumi:"grantCreationTokens"` 93 // The unique identifier for the grant. 94 GrantId *string `pulumi:"grantId"` 95 // The grant token for the created grant. For more information, see [Grant Tokens](http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token). 96 GrantToken *string `pulumi:"grantToken"` 97 // The principal that is given permission to perform the operations that the grant permits in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 98 GranteePrincipal *string `pulumi:"granteePrincipal"` 99 // The unique identifier for the customer master key (CMK) that the grant applies to. Specify the key ID or the Amazon Resource Name (ARN) of the CMK. To specify a CMK in a different AWS account, you must use the key ARN. 100 KeyId *string `pulumi:"keyId"` 101 // A friendly name for identifying the grant. 102 Name *string `pulumi:"name"` 103 // A list of operations that the grant permits. The permitted values are: `Decrypt`, `Encrypt`, `GenerateDataKey`, `GenerateDataKeyWithoutPlaintext`, `ReEncryptFrom`, `ReEncryptTo`, `Sign`, `Verify`, `GetPublicKey`, `CreateGrant`, `RetireGrant`, `DescribeKey`, `GenerateDataKeyPair`, or `GenerateDataKeyPairWithoutPlaintext`. 104 Operations []string `pulumi:"operations"` 105 // If set to false (the default) the grants will be revoked upon deletion, and if set to true the grants will try to be retired upon deletion. Note that retiring grants requires special permissions, hence why we default to revoking grants. 106 // See [RetireGrant](https://docs.aws.amazon.com/kms/latest/APIReference/API_RetireGrant.html) for more information. 107 RetireOnDelete *bool `pulumi:"retireOnDelete"` 108 // The principal that is given permission to retire the grant by using RetireGrant operation in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 109 RetiringPrincipal *string `pulumi:"retiringPrincipal"` 110 } 111 112 type GrantState struct { 113 // A structure that you can use to allow certain operations in the grant only when the desired encryption context is present. For more information about encryption context, see [Encryption Context](http://docs.aws.amazon.com/kms/latest/developerguide/encryption-context.html). 114 Constraints GrantConstraintArrayInput 115 // A list of grant tokens to be used when creating the grant. See [Grant Tokens](http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token) for more information about grant tokens. 116 GrantCreationTokens pulumi.StringArrayInput 117 // The unique identifier for the grant. 118 GrantId pulumi.StringPtrInput 119 // The grant token for the created grant. For more information, see [Grant Tokens](http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token). 120 GrantToken pulumi.StringPtrInput 121 // The principal that is given permission to perform the operations that the grant permits in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 122 GranteePrincipal pulumi.StringPtrInput 123 // The unique identifier for the customer master key (CMK) that the grant applies to. Specify the key ID or the Amazon Resource Name (ARN) of the CMK. To specify a CMK in a different AWS account, you must use the key ARN. 124 KeyId pulumi.StringPtrInput 125 // A friendly name for identifying the grant. 126 Name pulumi.StringPtrInput 127 // A list of operations that the grant permits. The permitted values are: `Decrypt`, `Encrypt`, `GenerateDataKey`, `GenerateDataKeyWithoutPlaintext`, `ReEncryptFrom`, `ReEncryptTo`, `Sign`, `Verify`, `GetPublicKey`, `CreateGrant`, `RetireGrant`, `DescribeKey`, `GenerateDataKeyPair`, or `GenerateDataKeyPairWithoutPlaintext`. 128 Operations pulumi.StringArrayInput 129 // If set to false (the default) the grants will be revoked upon deletion, and if set to true the grants will try to be retired upon deletion. Note that retiring grants requires special permissions, hence why we default to revoking grants. 130 // See [RetireGrant](https://docs.aws.amazon.com/kms/latest/APIReference/API_RetireGrant.html) for more information. 131 RetireOnDelete pulumi.BoolPtrInput 132 // The principal that is given permission to retire the grant by using RetireGrant operation in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 133 RetiringPrincipal pulumi.StringPtrInput 134 } 135 136 func (GrantState) ElementType() reflect.Type { 137 return reflect.TypeOf((*grantState)(nil)).Elem() 138 } 139 140 type grantArgs struct { 141 // A structure that you can use to allow certain operations in the grant only when the desired encryption context is present. For more information about encryption context, see [Encryption Context](http://docs.aws.amazon.com/kms/latest/developerguide/encryption-context.html). 142 Constraints []GrantConstraint `pulumi:"constraints"` 143 // A list of grant tokens to be used when creating the grant. See [Grant Tokens](http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token) for more information about grant tokens. 144 GrantCreationTokens []string `pulumi:"grantCreationTokens"` 145 // The principal that is given permission to perform the operations that the grant permits in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 146 GranteePrincipal string `pulumi:"granteePrincipal"` 147 // The unique identifier for the customer master key (CMK) that the grant applies to. Specify the key ID or the Amazon Resource Name (ARN) of the CMK. To specify a CMK in a different AWS account, you must use the key ARN. 148 KeyId string `pulumi:"keyId"` 149 // A friendly name for identifying the grant. 150 Name *string `pulumi:"name"` 151 // A list of operations that the grant permits. The permitted values are: `Decrypt`, `Encrypt`, `GenerateDataKey`, `GenerateDataKeyWithoutPlaintext`, `ReEncryptFrom`, `ReEncryptTo`, `Sign`, `Verify`, `GetPublicKey`, `CreateGrant`, `RetireGrant`, `DescribeKey`, `GenerateDataKeyPair`, or `GenerateDataKeyPairWithoutPlaintext`. 152 Operations []string `pulumi:"operations"` 153 // If set to false (the default) the grants will be revoked upon deletion, and if set to true the grants will try to be retired upon deletion. Note that retiring grants requires special permissions, hence why we default to revoking grants. 154 // See [RetireGrant](https://docs.aws.amazon.com/kms/latest/APIReference/API_RetireGrant.html) for more information. 155 RetireOnDelete *bool `pulumi:"retireOnDelete"` 156 // The principal that is given permission to retire the grant by using RetireGrant operation in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 157 RetiringPrincipal *string `pulumi:"retiringPrincipal"` 158 } 159 160 // The set of arguments for constructing a Grant resource. 161 type GrantArgs struct { 162 // A structure that you can use to allow certain operations in the grant only when the desired encryption context is present. For more information about encryption context, see [Encryption Context](http://docs.aws.amazon.com/kms/latest/developerguide/encryption-context.html). 163 Constraints GrantConstraintArrayInput 164 // A list of grant tokens to be used when creating the grant. See [Grant Tokens](http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token) for more information about grant tokens. 165 GrantCreationTokens pulumi.StringArrayInput 166 // The principal that is given permission to perform the operations that the grant permits in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 167 GranteePrincipal pulumi.StringInput 168 // The unique identifier for the customer master key (CMK) that the grant applies to. Specify the key ID or the Amazon Resource Name (ARN) of the CMK. To specify a CMK in a different AWS account, you must use the key ARN. 169 KeyId pulumi.StringInput 170 // A friendly name for identifying the grant. 171 Name pulumi.StringPtrInput 172 // A list of operations that the grant permits. The permitted values are: `Decrypt`, `Encrypt`, `GenerateDataKey`, `GenerateDataKeyWithoutPlaintext`, `ReEncryptFrom`, `ReEncryptTo`, `Sign`, `Verify`, `GetPublicKey`, `CreateGrant`, `RetireGrant`, `DescribeKey`, `GenerateDataKeyPair`, or `GenerateDataKeyPairWithoutPlaintext`. 173 Operations pulumi.StringArrayInput 174 // If set to false (the default) the grants will be revoked upon deletion, and if set to true the grants will try to be retired upon deletion. Note that retiring grants requires special permissions, hence why we default to revoking grants. 175 // See [RetireGrant](https://docs.aws.amazon.com/kms/latest/APIReference/API_RetireGrant.html) for more information. 176 RetireOnDelete pulumi.BoolPtrInput 177 // The principal that is given permission to retire the grant by using RetireGrant operation in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 178 RetiringPrincipal pulumi.StringPtrInput 179 } 180 181 func (GrantArgs) ElementType() reflect.Type { 182 return reflect.TypeOf((*grantArgs)(nil)).Elem() 183 } 184 185 type GrantInput interface { 186 pulumi.Input 187 188 ToGrantOutput() GrantOutput 189 ToGrantOutputWithContext(ctx context.Context) GrantOutput 190 } 191 192 func (*Grant) ElementType() reflect.Type { 193 return reflect.TypeOf((**Grant)(nil)).Elem() 194 } 195 196 func (i *Grant) ToGrantOutput() GrantOutput { 197 return i.ToGrantOutputWithContext(context.Background()) 198 } 199 200 func (i *Grant) ToGrantOutputWithContext(ctx context.Context) GrantOutput { 201 return pulumi.ToOutputWithContext(ctx, i).(GrantOutput) 202 } 203 204 // GrantArrayInput is an input type that accepts GrantArray and GrantArrayOutput values. 205 // You can construct a concrete instance of `GrantArrayInput` via: 206 // 207 // GrantArray{ GrantArgs{...} } 208 type GrantArrayInput interface { 209 pulumi.Input 210 211 ToGrantArrayOutput() GrantArrayOutput 212 ToGrantArrayOutputWithContext(context.Context) GrantArrayOutput 213 } 214 215 type GrantArray []GrantInput 216 217 func (GrantArray) ElementType() reflect.Type { 218 return reflect.TypeOf((*[]*Grant)(nil)).Elem() 219 } 220 221 func (i GrantArray) ToGrantArrayOutput() GrantArrayOutput { 222 return i.ToGrantArrayOutputWithContext(context.Background()) 223 } 224 225 func (i GrantArray) ToGrantArrayOutputWithContext(ctx context.Context) GrantArrayOutput { 226 return pulumi.ToOutputWithContext(ctx, i).(GrantArrayOutput) 227 } 228 229 // GrantMapInput is an input type that accepts GrantMap and GrantMapOutput values. 230 // You can construct a concrete instance of `GrantMapInput` via: 231 // 232 // GrantMap{ "key": GrantArgs{...} } 233 type GrantMapInput interface { 234 pulumi.Input 235 236 ToGrantMapOutput() GrantMapOutput 237 ToGrantMapOutputWithContext(context.Context) GrantMapOutput 238 } 239 240 type GrantMap map[string]GrantInput 241 242 func (GrantMap) ElementType() reflect.Type { 243 return reflect.TypeOf((*map[string]*Grant)(nil)).Elem() 244 } 245 246 func (i GrantMap) ToGrantMapOutput() GrantMapOutput { 247 return i.ToGrantMapOutputWithContext(context.Background()) 248 } 249 250 func (i GrantMap) ToGrantMapOutputWithContext(ctx context.Context) GrantMapOutput { 251 return pulumi.ToOutputWithContext(ctx, i).(GrantMapOutput) 252 } 253 254 type GrantOutput struct{ *pulumi.OutputState } 255 256 func (GrantOutput) ElementType() reflect.Type { 257 return reflect.TypeOf((**Grant)(nil)).Elem() 258 } 259 260 func (o GrantOutput) ToGrantOutput() GrantOutput { 261 return o 262 } 263 264 func (o GrantOutput) ToGrantOutputWithContext(ctx context.Context) GrantOutput { 265 return o 266 } 267 268 // A structure that you can use to allow certain operations in the grant only when the desired encryption context is present. For more information about encryption context, see [Encryption Context](http://docs.aws.amazon.com/kms/latest/developerguide/encryption-context.html). 269 func (o GrantOutput) Constraints() GrantConstraintArrayOutput { 270 return o.ApplyT(func(v *Grant) GrantConstraintArrayOutput { return v.Constraints }).(GrantConstraintArrayOutput) 271 } 272 273 // A list of grant tokens to be used when creating the grant. See [Grant Tokens](http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token) for more information about grant tokens. 274 func (o GrantOutput) GrantCreationTokens() pulumi.StringArrayOutput { 275 return o.ApplyT(func(v *Grant) pulumi.StringArrayOutput { return v.GrantCreationTokens }).(pulumi.StringArrayOutput) 276 } 277 278 // The unique identifier for the grant. 279 func (o GrantOutput) GrantId() pulumi.StringOutput { 280 return o.ApplyT(func(v *Grant) pulumi.StringOutput { return v.GrantId }).(pulumi.StringOutput) 281 } 282 283 // The grant token for the created grant. For more information, see [Grant Tokens](http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token). 284 func (o GrantOutput) GrantToken() pulumi.StringOutput { 285 return o.ApplyT(func(v *Grant) pulumi.StringOutput { return v.GrantToken }).(pulumi.StringOutput) 286 } 287 288 // The principal that is given permission to perform the operations that the grant permits in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 289 func (o GrantOutput) GranteePrincipal() pulumi.StringOutput { 290 return o.ApplyT(func(v *Grant) pulumi.StringOutput { return v.GranteePrincipal }).(pulumi.StringOutput) 291 } 292 293 // The unique identifier for the customer master key (CMK) that the grant applies to. Specify the key ID or the Amazon Resource Name (ARN) of the CMK. To specify a CMK in a different AWS account, you must use the key ARN. 294 func (o GrantOutput) KeyId() pulumi.StringOutput { 295 return o.ApplyT(func(v *Grant) pulumi.StringOutput { return v.KeyId }).(pulumi.StringOutput) 296 } 297 298 // A friendly name for identifying the grant. 299 func (o GrantOutput) Name() pulumi.StringOutput { 300 return o.ApplyT(func(v *Grant) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 301 } 302 303 // A list of operations that the grant permits. The permitted values are: `Decrypt`, `Encrypt`, `GenerateDataKey`, `GenerateDataKeyWithoutPlaintext`, `ReEncryptFrom`, `ReEncryptTo`, `Sign`, `Verify`, `GetPublicKey`, `CreateGrant`, `RetireGrant`, `DescribeKey`, `GenerateDataKeyPair`, or `GenerateDataKeyPairWithoutPlaintext`. 304 func (o GrantOutput) Operations() pulumi.StringArrayOutput { 305 return o.ApplyT(func(v *Grant) pulumi.StringArrayOutput { return v.Operations }).(pulumi.StringArrayOutput) 306 } 307 308 // If set to false (the default) the grants will be revoked upon deletion, and if set to true the grants will try to be retired upon deletion. Note that retiring grants requires special permissions, hence why we default to revoking grants. 309 // See [RetireGrant](https://docs.aws.amazon.com/kms/latest/APIReference/API_RetireGrant.html) for more information. 310 func (o GrantOutput) RetireOnDelete() pulumi.BoolPtrOutput { 311 return o.ApplyT(func(v *Grant) pulumi.BoolPtrOutput { return v.RetireOnDelete }).(pulumi.BoolPtrOutput) 312 } 313 314 // The principal that is given permission to retire the grant by using RetireGrant operation in ARN format. Note that due to eventual consistency issues around IAM principals, the providers's state may not always be refreshed to reflect what is true in AWS. 315 func (o GrantOutput) RetiringPrincipal() pulumi.StringPtrOutput { 316 return o.ApplyT(func(v *Grant) pulumi.StringPtrOutput { return v.RetiringPrincipal }).(pulumi.StringPtrOutput) 317 } 318 319 type GrantArrayOutput struct{ *pulumi.OutputState } 320 321 func (GrantArrayOutput) ElementType() reflect.Type { 322 return reflect.TypeOf((*[]*Grant)(nil)).Elem() 323 } 324 325 func (o GrantArrayOutput) ToGrantArrayOutput() GrantArrayOutput { 326 return o 327 } 328 329 func (o GrantArrayOutput) ToGrantArrayOutputWithContext(ctx context.Context) GrantArrayOutput { 330 return o 331 } 332 333 func (o GrantArrayOutput) Index(i pulumi.IntInput) GrantOutput { 334 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Grant { 335 return vs[0].([]*Grant)[vs[1].(int)] 336 }).(GrantOutput) 337 } 338 339 type GrantMapOutput struct{ *pulumi.OutputState } 340 341 func (GrantMapOutput) ElementType() reflect.Type { 342 return reflect.TypeOf((*map[string]*Grant)(nil)).Elem() 343 } 344 345 func (o GrantMapOutput) ToGrantMapOutput() GrantMapOutput { 346 return o 347 } 348 349 func (o GrantMapOutput) ToGrantMapOutputWithContext(ctx context.Context) GrantMapOutput { 350 return o 351 } 352 353 func (o GrantMapOutput) MapIndex(k pulumi.StringInput) GrantOutput { 354 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Grant { 355 return vs[0].(map[string]*Grant)[vs[1].(string)] 356 }).(GrantOutput) 357 } 358 359 func init() { 360 pulumi.RegisterInputType(reflect.TypeOf((*GrantInput)(nil)).Elem(), &Grant{}) 361 pulumi.RegisterInputType(reflect.TypeOf((*GrantArrayInput)(nil)).Elem(), GrantArray{}) 362 pulumi.RegisterInputType(reflect.TypeOf((*GrantMapInput)(nil)).Elem(), GrantMap{}) 363 pulumi.RegisterOutputType(GrantOutput{}) 364 pulumi.RegisterOutputType(GrantArrayOutput{}) 365 pulumi.RegisterOutputType(GrantMapOutput{}) 366 }