github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/kms/alias.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 an alias for a KMS customer master key. AWS Console enforces 1-to-1 mapping between aliases & keys, 16 // but API (hence this provider too) allows you to create as many aliases as 17 // the [account limits](http://docs.aws.amazon.com/kms/latest/developerguide/limits.html) allow you. 18 // 19 // ## Example Usage 20 // 21 // <!--Start PulumiCodeChooser --> 22 // ```go 23 // package main 24 // 25 // import ( 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // a, err := kms.NewKey(ctx, "a", nil) 35 // if err != nil { 36 // return err 37 // } 38 // _, err = kms.NewAlias(ctx, "a", &kms.AliasArgs{ 39 // Name: pulumi.String("alias/my-key-alias"), 40 // TargetKeyId: a.KeyId, 41 // }) 42 // if err != nil { 43 // return err 44 // } 45 // return nil 46 // }) 47 // } 48 // 49 // ``` 50 // <!--End PulumiCodeChooser --> 51 // 52 // ## Import 53 // 54 // Using `pulumi import`, import KMS aliases using the `name`. For example: 55 // 56 // ```sh 57 // $ pulumi import aws:kms/alias:Alias a alias/my-key-alias 58 // ``` 59 type Alias struct { 60 pulumi.CustomResourceState 61 62 // The Amazon Resource Name (ARN) of the key alias. 63 Arn pulumi.StringOutput `pulumi:"arn"` 64 // The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/) 65 Name pulumi.StringOutput `pulumi:"name"` 66 // Creates an unique alias beginning with the specified prefix. 67 // The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with `name`. 68 NamePrefix pulumi.StringOutput `pulumi:"namePrefix"` 69 // The Amazon Resource Name (ARN) of the target key identifier. 70 TargetKeyArn pulumi.StringOutput `pulumi:"targetKeyArn"` 71 // Identifier for the key for which the alias is for, can be either an ARN or key_id. 72 TargetKeyId pulumi.StringOutput `pulumi:"targetKeyId"` 73 } 74 75 // NewAlias registers a new resource with the given unique name, arguments, and options. 76 func NewAlias(ctx *pulumi.Context, 77 name string, args *AliasArgs, opts ...pulumi.ResourceOption) (*Alias, error) { 78 if args == nil { 79 return nil, errors.New("missing one or more required arguments") 80 } 81 82 if args.TargetKeyId == nil { 83 return nil, errors.New("invalid value for required argument 'TargetKeyId'") 84 } 85 opts = internal.PkgResourceDefaultOpts(opts) 86 var resource Alias 87 err := ctx.RegisterResource("aws:kms/alias:Alias", name, args, &resource, opts...) 88 if err != nil { 89 return nil, err 90 } 91 return &resource, nil 92 } 93 94 // GetAlias gets an existing Alias resource's state with the given name, ID, and optional 95 // state properties that are used to uniquely qualify the lookup (nil if not required). 96 func GetAlias(ctx *pulumi.Context, 97 name string, id pulumi.IDInput, state *AliasState, opts ...pulumi.ResourceOption) (*Alias, error) { 98 var resource Alias 99 err := ctx.ReadResource("aws:kms/alias:Alias", name, id, state, &resource, opts...) 100 if err != nil { 101 return nil, err 102 } 103 return &resource, nil 104 } 105 106 // Input properties used for looking up and filtering Alias resources. 107 type aliasState struct { 108 // The Amazon Resource Name (ARN) of the key alias. 109 Arn *string `pulumi:"arn"` 110 // The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/) 111 Name *string `pulumi:"name"` 112 // Creates an unique alias beginning with the specified prefix. 113 // The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with `name`. 114 NamePrefix *string `pulumi:"namePrefix"` 115 // The Amazon Resource Name (ARN) of the target key identifier. 116 TargetKeyArn *string `pulumi:"targetKeyArn"` 117 // Identifier for the key for which the alias is for, can be either an ARN or key_id. 118 TargetKeyId *string `pulumi:"targetKeyId"` 119 } 120 121 type AliasState struct { 122 // The Amazon Resource Name (ARN) of the key alias. 123 Arn pulumi.StringPtrInput 124 // The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/) 125 Name pulumi.StringPtrInput 126 // Creates an unique alias beginning with the specified prefix. 127 // The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with `name`. 128 NamePrefix pulumi.StringPtrInput 129 // The Amazon Resource Name (ARN) of the target key identifier. 130 TargetKeyArn pulumi.StringPtrInput 131 // Identifier for the key for which the alias is for, can be either an ARN or key_id. 132 TargetKeyId pulumi.StringPtrInput 133 } 134 135 func (AliasState) ElementType() reflect.Type { 136 return reflect.TypeOf((*aliasState)(nil)).Elem() 137 } 138 139 type aliasArgs struct { 140 // The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/) 141 Name *string `pulumi:"name"` 142 // Creates an unique alias beginning with the specified prefix. 143 // The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with `name`. 144 NamePrefix *string `pulumi:"namePrefix"` 145 // Identifier for the key for which the alias is for, can be either an ARN or key_id. 146 TargetKeyId string `pulumi:"targetKeyId"` 147 } 148 149 // The set of arguments for constructing a Alias resource. 150 type AliasArgs struct { 151 // The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/) 152 Name pulumi.StringPtrInput 153 // Creates an unique alias beginning with the specified prefix. 154 // The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with `name`. 155 NamePrefix pulumi.StringPtrInput 156 // Identifier for the key for which the alias is for, can be either an ARN or key_id. 157 TargetKeyId pulumi.StringInput 158 } 159 160 func (AliasArgs) ElementType() reflect.Type { 161 return reflect.TypeOf((*aliasArgs)(nil)).Elem() 162 } 163 164 type AliasInput interface { 165 pulumi.Input 166 167 ToAliasOutput() AliasOutput 168 ToAliasOutputWithContext(ctx context.Context) AliasOutput 169 } 170 171 func (*Alias) ElementType() reflect.Type { 172 return reflect.TypeOf((**Alias)(nil)).Elem() 173 } 174 175 func (i *Alias) ToAliasOutput() AliasOutput { 176 return i.ToAliasOutputWithContext(context.Background()) 177 } 178 179 func (i *Alias) ToAliasOutputWithContext(ctx context.Context) AliasOutput { 180 return pulumi.ToOutputWithContext(ctx, i).(AliasOutput) 181 } 182 183 // AliasArrayInput is an input type that accepts AliasArray and AliasArrayOutput values. 184 // You can construct a concrete instance of `AliasArrayInput` via: 185 // 186 // AliasArray{ AliasArgs{...} } 187 type AliasArrayInput interface { 188 pulumi.Input 189 190 ToAliasArrayOutput() AliasArrayOutput 191 ToAliasArrayOutputWithContext(context.Context) AliasArrayOutput 192 } 193 194 type AliasArray []AliasInput 195 196 func (AliasArray) ElementType() reflect.Type { 197 return reflect.TypeOf((*[]*Alias)(nil)).Elem() 198 } 199 200 func (i AliasArray) ToAliasArrayOutput() AliasArrayOutput { 201 return i.ToAliasArrayOutputWithContext(context.Background()) 202 } 203 204 func (i AliasArray) ToAliasArrayOutputWithContext(ctx context.Context) AliasArrayOutput { 205 return pulumi.ToOutputWithContext(ctx, i).(AliasArrayOutput) 206 } 207 208 // AliasMapInput is an input type that accepts AliasMap and AliasMapOutput values. 209 // You can construct a concrete instance of `AliasMapInput` via: 210 // 211 // AliasMap{ "key": AliasArgs{...} } 212 type AliasMapInput interface { 213 pulumi.Input 214 215 ToAliasMapOutput() AliasMapOutput 216 ToAliasMapOutputWithContext(context.Context) AliasMapOutput 217 } 218 219 type AliasMap map[string]AliasInput 220 221 func (AliasMap) ElementType() reflect.Type { 222 return reflect.TypeOf((*map[string]*Alias)(nil)).Elem() 223 } 224 225 func (i AliasMap) ToAliasMapOutput() AliasMapOutput { 226 return i.ToAliasMapOutputWithContext(context.Background()) 227 } 228 229 func (i AliasMap) ToAliasMapOutputWithContext(ctx context.Context) AliasMapOutput { 230 return pulumi.ToOutputWithContext(ctx, i).(AliasMapOutput) 231 } 232 233 type AliasOutput struct{ *pulumi.OutputState } 234 235 func (AliasOutput) ElementType() reflect.Type { 236 return reflect.TypeOf((**Alias)(nil)).Elem() 237 } 238 239 func (o AliasOutput) ToAliasOutput() AliasOutput { 240 return o 241 } 242 243 func (o AliasOutput) ToAliasOutputWithContext(ctx context.Context) AliasOutput { 244 return o 245 } 246 247 // The Amazon Resource Name (ARN) of the key alias. 248 func (o AliasOutput) Arn() pulumi.StringOutput { 249 return o.ApplyT(func(v *Alias) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput) 250 } 251 252 // The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/) 253 func (o AliasOutput) Name() pulumi.StringOutput { 254 return o.ApplyT(func(v *Alias) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 255 } 256 257 // Creates an unique alias beginning with the specified prefix. 258 // The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with `name`. 259 func (o AliasOutput) NamePrefix() pulumi.StringOutput { 260 return o.ApplyT(func(v *Alias) pulumi.StringOutput { return v.NamePrefix }).(pulumi.StringOutput) 261 } 262 263 // The Amazon Resource Name (ARN) of the target key identifier. 264 func (o AliasOutput) TargetKeyArn() pulumi.StringOutput { 265 return o.ApplyT(func(v *Alias) pulumi.StringOutput { return v.TargetKeyArn }).(pulumi.StringOutput) 266 } 267 268 // Identifier for the key for which the alias is for, can be either an ARN or key_id. 269 func (o AliasOutput) TargetKeyId() pulumi.StringOutput { 270 return o.ApplyT(func(v *Alias) pulumi.StringOutput { return v.TargetKeyId }).(pulumi.StringOutput) 271 } 272 273 type AliasArrayOutput struct{ *pulumi.OutputState } 274 275 func (AliasArrayOutput) ElementType() reflect.Type { 276 return reflect.TypeOf((*[]*Alias)(nil)).Elem() 277 } 278 279 func (o AliasArrayOutput) ToAliasArrayOutput() AliasArrayOutput { 280 return o 281 } 282 283 func (o AliasArrayOutput) ToAliasArrayOutputWithContext(ctx context.Context) AliasArrayOutput { 284 return o 285 } 286 287 func (o AliasArrayOutput) Index(i pulumi.IntInput) AliasOutput { 288 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Alias { 289 return vs[0].([]*Alias)[vs[1].(int)] 290 }).(AliasOutput) 291 } 292 293 type AliasMapOutput struct{ *pulumi.OutputState } 294 295 func (AliasMapOutput) ElementType() reflect.Type { 296 return reflect.TypeOf((*map[string]*Alias)(nil)).Elem() 297 } 298 299 func (o AliasMapOutput) ToAliasMapOutput() AliasMapOutput { 300 return o 301 } 302 303 func (o AliasMapOutput) ToAliasMapOutputWithContext(ctx context.Context) AliasMapOutput { 304 return o 305 } 306 307 func (o AliasMapOutput) MapIndex(k pulumi.StringInput) AliasOutput { 308 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Alias { 309 return vs[0].(map[string]*Alias)[vs[1].(string)] 310 }).(AliasOutput) 311 } 312 313 func init() { 314 pulumi.RegisterInputType(reflect.TypeOf((*AliasInput)(nil)).Elem(), &Alias{}) 315 pulumi.RegisterInputType(reflect.TypeOf((*AliasArrayInput)(nil)).Elem(), AliasArray{}) 316 pulumi.RegisterInputType(reflect.TypeOf((*AliasMapInput)(nil)).Elem(), AliasMap{}) 317 pulumi.RegisterOutputType(AliasOutput{}) 318 pulumi.RegisterOutputType(AliasArrayOutput{}) 319 pulumi.RegisterOutputType(AliasMapOutput{}) 320 }