github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/lambda/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 lambda 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 // Creates a Lambda function alias. Creates an alias that points to the specified Lambda function version. 16 // 17 // For information about Lambda and how to use it, see [What is AWS Lambda?](http://docs.aws.amazon.com/lambda/latest/dg/welcome.html) 18 // For information about function aliases, see [CreateAlias](http://docs.aws.amazon.com/lambda/latest/dg/API_CreateAlias.html) and [AliasRoutingConfiguration](https://docs.aws.amazon.com/lambda/latest/dg/API_AliasRoutingConfiguration.html) in the API docs. 19 // 20 // ## Example Usage 21 // 22 // <!--Start PulumiCodeChooser --> 23 // ```go 24 // package main 25 // 26 // import ( 27 // 28 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lambda" 29 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 30 // 31 // ) 32 // 33 // func main() { 34 // pulumi.Run(func(ctx *pulumi.Context) error { 35 // _, err := lambda.NewAlias(ctx, "test_lambda_alias", &lambda.AliasArgs{ 36 // Name: pulumi.String("my_alias"), 37 // Description: pulumi.String("a sample description"), 38 // FunctionName: pulumi.Any(lambdaFunctionTest.Arn), 39 // FunctionVersion: pulumi.String("1"), 40 // RoutingConfig: &lambda.AliasRoutingConfigArgs{ 41 // AdditionalVersionWeights: pulumi.Float64Map{ 42 // "2": pulumi.Float64(0.5), 43 // }, 44 // }, 45 // }) 46 // if err != nil { 47 // return err 48 // } 49 // return nil 50 // }) 51 // } 52 // 53 // ``` 54 // <!--End PulumiCodeChooser --> 55 // 56 // ## Import 57 // 58 // Using `pulumi import`, import Lambda Function Aliases using the `function_name/alias`. For example: 59 // 60 // ```sh 61 // $ pulumi import aws:lambda/alias:Alias test_lambda_alias my_test_lambda_function/my_alias 62 // ``` 63 type Alias struct { 64 pulumi.CustomResourceState 65 66 // The Amazon Resource Name (ARN) identifying your Lambda function alias. 67 Arn pulumi.StringOutput `pulumi:"arn"` 68 // Description of the alias. 69 Description pulumi.StringPtrOutput `pulumi:"description"` 70 // Lambda Function name or ARN. 71 FunctionName pulumi.StringOutput `pulumi:"functionName"` 72 // Lambda function version for which you are creating the alias. Pattern: `(\$LATEST|[0-9]+)`. 73 FunctionVersion pulumi.StringOutput `pulumi:"functionVersion"` 74 // The ARN to be used for invoking Lambda Function from API Gateway - to be used in `apigateway.Integration`'s `uri` 75 InvokeArn pulumi.StringOutput `pulumi:"invokeArn"` 76 // Name for the alias you are creating. Pattern: `(?!^[0-9]+$)([a-zA-Z0-9-_]+)` 77 Name pulumi.StringOutput `pulumi:"name"` 78 // The Lambda alias' route configuration settings. Fields documented below 79 RoutingConfig AliasRoutingConfigPtrOutput `pulumi:"routingConfig"` 80 } 81 82 // NewAlias registers a new resource with the given unique name, arguments, and options. 83 func NewAlias(ctx *pulumi.Context, 84 name string, args *AliasArgs, opts ...pulumi.ResourceOption) (*Alias, error) { 85 if args == nil { 86 return nil, errors.New("missing one or more required arguments") 87 } 88 89 if args.FunctionName == nil { 90 return nil, errors.New("invalid value for required argument 'FunctionName'") 91 } 92 if args.FunctionVersion == nil { 93 return nil, errors.New("invalid value for required argument 'FunctionVersion'") 94 } 95 opts = internal.PkgResourceDefaultOpts(opts) 96 var resource Alias 97 err := ctx.RegisterResource("aws:lambda/alias:Alias", name, args, &resource, opts...) 98 if err != nil { 99 return nil, err 100 } 101 return &resource, nil 102 } 103 104 // GetAlias gets an existing Alias resource's state with the given name, ID, and optional 105 // state properties that are used to uniquely qualify the lookup (nil if not required). 106 func GetAlias(ctx *pulumi.Context, 107 name string, id pulumi.IDInput, state *AliasState, opts ...pulumi.ResourceOption) (*Alias, error) { 108 var resource Alias 109 err := ctx.ReadResource("aws:lambda/alias:Alias", name, id, state, &resource, opts...) 110 if err != nil { 111 return nil, err 112 } 113 return &resource, nil 114 } 115 116 // Input properties used for looking up and filtering Alias resources. 117 type aliasState struct { 118 // The Amazon Resource Name (ARN) identifying your Lambda function alias. 119 Arn *string `pulumi:"arn"` 120 // Description of the alias. 121 Description *string `pulumi:"description"` 122 // Lambda Function name or ARN. 123 FunctionName *string `pulumi:"functionName"` 124 // Lambda function version for which you are creating the alias. Pattern: `(\$LATEST|[0-9]+)`. 125 FunctionVersion *string `pulumi:"functionVersion"` 126 // The ARN to be used for invoking Lambda Function from API Gateway - to be used in `apigateway.Integration`'s `uri` 127 InvokeArn *string `pulumi:"invokeArn"` 128 // Name for the alias you are creating. Pattern: `(?!^[0-9]+$)([a-zA-Z0-9-_]+)` 129 Name *string `pulumi:"name"` 130 // The Lambda alias' route configuration settings. Fields documented below 131 RoutingConfig *AliasRoutingConfig `pulumi:"routingConfig"` 132 } 133 134 type AliasState struct { 135 // The Amazon Resource Name (ARN) identifying your Lambda function alias. 136 Arn pulumi.StringPtrInput 137 // Description of the alias. 138 Description pulumi.StringPtrInput 139 // Lambda Function name or ARN. 140 FunctionName pulumi.StringPtrInput 141 // Lambda function version for which you are creating the alias. Pattern: `(\$LATEST|[0-9]+)`. 142 FunctionVersion pulumi.StringPtrInput 143 // The ARN to be used for invoking Lambda Function from API Gateway - to be used in `apigateway.Integration`'s `uri` 144 InvokeArn pulumi.StringPtrInput 145 // Name for the alias you are creating. Pattern: `(?!^[0-9]+$)([a-zA-Z0-9-_]+)` 146 Name pulumi.StringPtrInput 147 // The Lambda alias' route configuration settings. Fields documented below 148 RoutingConfig AliasRoutingConfigPtrInput 149 } 150 151 func (AliasState) ElementType() reflect.Type { 152 return reflect.TypeOf((*aliasState)(nil)).Elem() 153 } 154 155 type aliasArgs struct { 156 // Description of the alias. 157 Description *string `pulumi:"description"` 158 // Lambda Function name or ARN. 159 FunctionName string `pulumi:"functionName"` 160 // Lambda function version for which you are creating the alias. Pattern: `(\$LATEST|[0-9]+)`. 161 FunctionVersion string `pulumi:"functionVersion"` 162 // Name for the alias you are creating. Pattern: `(?!^[0-9]+$)([a-zA-Z0-9-_]+)` 163 Name *string `pulumi:"name"` 164 // The Lambda alias' route configuration settings. Fields documented below 165 RoutingConfig *AliasRoutingConfig `pulumi:"routingConfig"` 166 } 167 168 // The set of arguments for constructing a Alias resource. 169 type AliasArgs struct { 170 // Description of the alias. 171 Description pulumi.StringPtrInput 172 // Lambda Function name or ARN. 173 FunctionName pulumi.StringInput 174 // Lambda function version for which you are creating the alias. Pattern: `(\$LATEST|[0-9]+)`. 175 FunctionVersion pulumi.StringInput 176 // Name for the alias you are creating. Pattern: `(?!^[0-9]+$)([a-zA-Z0-9-_]+)` 177 Name pulumi.StringPtrInput 178 // The Lambda alias' route configuration settings. Fields documented below 179 RoutingConfig AliasRoutingConfigPtrInput 180 } 181 182 func (AliasArgs) ElementType() reflect.Type { 183 return reflect.TypeOf((*aliasArgs)(nil)).Elem() 184 } 185 186 type AliasInput interface { 187 pulumi.Input 188 189 ToAliasOutput() AliasOutput 190 ToAliasOutputWithContext(ctx context.Context) AliasOutput 191 } 192 193 func (*Alias) ElementType() reflect.Type { 194 return reflect.TypeOf((**Alias)(nil)).Elem() 195 } 196 197 func (i *Alias) ToAliasOutput() AliasOutput { 198 return i.ToAliasOutputWithContext(context.Background()) 199 } 200 201 func (i *Alias) ToAliasOutputWithContext(ctx context.Context) AliasOutput { 202 return pulumi.ToOutputWithContext(ctx, i).(AliasOutput) 203 } 204 205 // AliasArrayInput is an input type that accepts AliasArray and AliasArrayOutput values. 206 // You can construct a concrete instance of `AliasArrayInput` via: 207 // 208 // AliasArray{ AliasArgs{...} } 209 type AliasArrayInput interface { 210 pulumi.Input 211 212 ToAliasArrayOutput() AliasArrayOutput 213 ToAliasArrayOutputWithContext(context.Context) AliasArrayOutput 214 } 215 216 type AliasArray []AliasInput 217 218 func (AliasArray) ElementType() reflect.Type { 219 return reflect.TypeOf((*[]*Alias)(nil)).Elem() 220 } 221 222 func (i AliasArray) ToAliasArrayOutput() AliasArrayOutput { 223 return i.ToAliasArrayOutputWithContext(context.Background()) 224 } 225 226 func (i AliasArray) ToAliasArrayOutputWithContext(ctx context.Context) AliasArrayOutput { 227 return pulumi.ToOutputWithContext(ctx, i).(AliasArrayOutput) 228 } 229 230 // AliasMapInput is an input type that accepts AliasMap and AliasMapOutput values. 231 // You can construct a concrete instance of `AliasMapInput` via: 232 // 233 // AliasMap{ "key": AliasArgs{...} } 234 type AliasMapInput interface { 235 pulumi.Input 236 237 ToAliasMapOutput() AliasMapOutput 238 ToAliasMapOutputWithContext(context.Context) AliasMapOutput 239 } 240 241 type AliasMap map[string]AliasInput 242 243 func (AliasMap) ElementType() reflect.Type { 244 return reflect.TypeOf((*map[string]*Alias)(nil)).Elem() 245 } 246 247 func (i AliasMap) ToAliasMapOutput() AliasMapOutput { 248 return i.ToAliasMapOutputWithContext(context.Background()) 249 } 250 251 func (i AliasMap) ToAliasMapOutputWithContext(ctx context.Context) AliasMapOutput { 252 return pulumi.ToOutputWithContext(ctx, i).(AliasMapOutput) 253 } 254 255 type AliasOutput struct{ *pulumi.OutputState } 256 257 func (AliasOutput) ElementType() reflect.Type { 258 return reflect.TypeOf((**Alias)(nil)).Elem() 259 } 260 261 func (o AliasOutput) ToAliasOutput() AliasOutput { 262 return o 263 } 264 265 func (o AliasOutput) ToAliasOutputWithContext(ctx context.Context) AliasOutput { 266 return o 267 } 268 269 // The Amazon Resource Name (ARN) identifying your Lambda function alias. 270 func (o AliasOutput) Arn() pulumi.StringOutput { 271 return o.ApplyT(func(v *Alias) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput) 272 } 273 274 // Description of the alias. 275 func (o AliasOutput) Description() pulumi.StringPtrOutput { 276 return o.ApplyT(func(v *Alias) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput) 277 } 278 279 // Lambda Function name or ARN. 280 func (o AliasOutput) FunctionName() pulumi.StringOutput { 281 return o.ApplyT(func(v *Alias) pulumi.StringOutput { return v.FunctionName }).(pulumi.StringOutput) 282 } 283 284 // Lambda function version for which you are creating the alias. Pattern: `(\$LATEST|[0-9]+)`. 285 func (o AliasOutput) FunctionVersion() pulumi.StringOutput { 286 return o.ApplyT(func(v *Alias) pulumi.StringOutput { return v.FunctionVersion }).(pulumi.StringOutput) 287 } 288 289 // The ARN to be used for invoking Lambda Function from API Gateway - to be used in `apigateway.Integration`'s `uri` 290 func (o AliasOutput) InvokeArn() pulumi.StringOutput { 291 return o.ApplyT(func(v *Alias) pulumi.StringOutput { return v.InvokeArn }).(pulumi.StringOutput) 292 } 293 294 // Name for the alias you are creating. Pattern: `(?!^[0-9]+$)([a-zA-Z0-9-_]+)` 295 func (o AliasOutput) Name() pulumi.StringOutput { 296 return o.ApplyT(func(v *Alias) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 297 } 298 299 // The Lambda alias' route configuration settings. Fields documented below 300 func (o AliasOutput) RoutingConfig() AliasRoutingConfigPtrOutput { 301 return o.ApplyT(func(v *Alias) AliasRoutingConfigPtrOutput { return v.RoutingConfig }).(AliasRoutingConfigPtrOutput) 302 } 303 304 type AliasArrayOutput struct{ *pulumi.OutputState } 305 306 func (AliasArrayOutput) ElementType() reflect.Type { 307 return reflect.TypeOf((*[]*Alias)(nil)).Elem() 308 } 309 310 func (o AliasArrayOutput) ToAliasArrayOutput() AliasArrayOutput { 311 return o 312 } 313 314 func (o AliasArrayOutput) ToAliasArrayOutputWithContext(ctx context.Context) AliasArrayOutput { 315 return o 316 } 317 318 func (o AliasArrayOutput) Index(i pulumi.IntInput) AliasOutput { 319 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Alias { 320 return vs[0].([]*Alias)[vs[1].(int)] 321 }).(AliasOutput) 322 } 323 324 type AliasMapOutput struct{ *pulumi.OutputState } 325 326 func (AliasMapOutput) ElementType() reflect.Type { 327 return reflect.TypeOf((*map[string]*Alias)(nil)).Elem() 328 } 329 330 func (o AliasMapOutput) ToAliasMapOutput() AliasMapOutput { 331 return o 332 } 333 334 func (o AliasMapOutput) ToAliasMapOutputWithContext(ctx context.Context) AliasMapOutput { 335 return o 336 } 337 338 func (o AliasMapOutput) MapIndex(k pulumi.StringInput) AliasOutput { 339 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Alias { 340 return vs[0].(map[string]*Alias)[vs[1].(string)] 341 }).(AliasOutput) 342 } 343 344 func init() { 345 pulumi.RegisterInputType(reflect.TypeOf((*AliasInput)(nil)).Elem(), &Alias{}) 346 pulumi.RegisterInputType(reflect.TypeOf((*AliasArrayInput)(nil)).Elem(), AliasArray{}) 347 pulumi.RegisterInputType(reflect.TypeOf((*AliasMapInput)(nil)).Elem(), AliasMap{}) 348 pulumi.RegisterOutputType(AliasOutput{}) 349 pulumi.RegisterOutputType(AliasArrayOutput{}) 350 pulumi.RegisterOutputType(AliasMapOutput{}) 351 }