/
api_op_CreateFunction.go
373 lines (310 loc) · 14 KB
/
api_op_CreateFunction.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
// Code generated by smithy-go-codegen DO NOT EDIT.
package lambda
import (
"context"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/service/lambda/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Creates a Lambda function. To create a function, you need a deployment package
// (https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html) and
// an execution role
// (https://docs.aws.amazon.com/lambda/latest/dg/intro-permission-model.html#lambda-intro-execution-role).
// The deployment package is a .zip file archive or container image that contains
// your function code. The execution role grants the function permission to use
// Amazon Web Services services, such as Amazon CloudWatch Logs for log streaming
// and X-Ray for request tracing. You set the package type to Image if the
// deployment package is a container image
// (https://docs.aws.amazon.com/lambda/latest/dg/lambda-images.html). For a
// container image, the code property must include the URI of a container image in
// the Amazon ECR registry. You do not need to specify the handler and runtime
// properties. You set the package type to Zip if the deployment package is a .zip
// file archive
// (https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html#gettingstarted-package-zip).
// For a .zip file archive, the code property specifies the location of the .zip
// file. You must also specify the handler and runtime properties. When you create
// a function, Lambda provisions an instance of the function and its supporting
// resources. If your function connects to a VPC, this process can take a minute or
// so. During this time, you can't invoke or modify the function. The State,
// StateReason, and StateReasonCode fields in the response from
// GetFunctionConfiguration indicate when the function is ready to invoke. For more
// information, see Function States
// (https://docs.aws.amazon.com/lambda/latest/dg/functions-states.html). A function
// has an unpublished version, and can have published versions and aliases. The
// unpublished version changes when you update your function's code and
// configuration. A published version is a snapshot of your function code and
// configuration that can't be changed. An alias is a named resource that maps to a
// version, and can be changed to map to a different version. Use the Publish
// parameter to create version 1 of your function from its initial configuration.
// The other parameters let you configure version-specific and function-level
// settings. You can modify version-specific settings later with
// UpdateFunctionConfiguration. Function-level settings apply to both the
// unpublished and published versions of the function, and include tags
// (TagResource) and per-function concurrency limits (PutFunctionConcurrency). You
// can use code signing if your deployment package is a .zip file archive. To
// enable code signing for this function, specify the ARN of a code-signing
// configuration. When a user attempts to deploy a code package with
// UpdateFunctionCode, Lambda checks that the code package has a valid signature
// from a trusted publisher. The code-signing configuration includes set set of
// signing profiles, which define the trusted publishers for this function. If
// another account or an Amazon Web Services service invokes your function, use
// AddPermission to grant permission by creating a resource-based IAM policy. You
// can grant permissions at the function level, on a version, or on an alias. To
// invoke your function directly, use Invoke. To invoke your function in response
// to events in other Amazon Web Services services, create an event source mapping
// (CreateEventSourceMapping), or configure a function trigger in the other
// service. For more information, see Invoking Functions
// (https://docs.aws.amazon.com/lambda/latest/dg/lambda-invocation.html).
func (c *Client) CreateFunction(ctx context.Context, params *CreateFunctionInput, optFns ...func(*Options)) (*CreateFunctionOutput, error) {
if params == nil {
params = &CreateFunctionInput{}
}
result, metadata, err := c.invokeOperation(ctx, "CreateFunction", params, optFns, c.addOperationCreateFunctionMiddlewares)
if err != nil {
return nil, err
}
out := result.(*CreateFunctionOutput)
out.ResultMetadata = metadata
return out, nil
}
type CreateFunctionInput struct {
// The code for the function.
//
// This member is required.
Code *types.FunctionCode
// The name of the Lambda function. Name formats
//
// * Function name - my-function.
//
// *
// Function ARN - arn:aws:lambda:us-west-2:123456789012:function:my-function.
//
// *
// Partial ARN - 123456789012:function:my-function.
//
// The length constraint applies
// only to the full ARN. If you specify only the function name, it is limited to 64
// characters in length.
//
// This member is required.
FunctionName *string
// The Amazon Resource Name (ARN) of the function's execution role.
//
// This member is required.
Role *string
// To enable code signing for this function, specify the ARN of a code-signing
// configuration. A code-signing configuration includes a set of signing profiles,
// which define the trusted publishers for this function.
CodeSigningConfigArn *string
// A dead letter queue configuration that specifies the queue or topic where Lambda
// sends asynchronous events when they fail processing. For more information, see
// Dead Letter Queues
// (https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#dlq).
DeadLetterConfig *types.DeadLetterConfig
// A description of the function.
Description *string
// Environment variables that are accessible from function code during execution.
Environment *types.Environment
// Connection settings for an Amazon EFS file system.
FileSystemConfigs []types.FileSystemConfig
// The name of the method within your code that Lambda calls to execute your
// function. The format includes the file name. It can also include namespaces and
// other qualifiers, depending on the runtime. For more information, see
// Programming Model
// (https://docs.aws.amazon.com/lambda/latest/dg/programming-model-v2.html).
Handler *string
// Container image configuration values
// (https://docs.aws.amazon.com/lambda/latest/dg/configuration-images.html#configuration-images-settings)
// that override the values in the container image Dockerfile.
ImageConfig *types.ImageConfig
// The ARN of the Amazon Web Services Key Management Service (KMS) key that's used
// to encrypt your function's environment variables. If it's not provided, Lambda
// uses a default service key.
KMSKeyArn *string
// A list of function layers
// (https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) to add
// to the function's execution environment. Specify each layer by its ARN,
// including the version.
Layers []string
// The amount of memory available to the function
// (https://docs.aws.amazon.com/lambda/latest/dg/configuration-memory.html) at
// runtime. Increasing the function memory also increases its CPU allocation. The
// default value is 128 MB. The value can be any multiple of 1 MB.
MemorySize *int32
// The type of deployment package. Set to Image for container image and set Zip for
// ZIP archive.
PackageType types.PackageType
// Set to true to publish the first version of the function during creation.
Publish bool
// The identifier of the function's runtime
// (https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html).
Runtime types.Runtime
// A list of tags (https://docs.aws.amazon.com/lambda/latest/dg/tagging.html) to
// apply to the function.
Tags map[string]string
// The amount of time that Lambda allows a function to run before stopping it. The
// default is 3 seconds. The maximum allowed value is 900 seconds. For additional
// information, see Lambda execution environment
// (https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html).
Timeout *int32
// Set Mode to Active to sample and trace a subset of incoming requests with X-Ray
// (https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html).
TracingConfig *types.TracingConfig
// For network connectivity to Amazon Web Services resources in a VPC, specify a
// list of security groups and subnets in the VPC. When you connect a function to a
// VPC, it can only access resources and the internet through that VPC. For more
// information, see VPC Settings
// (https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html).
VpcConfig *types.VpcConfig
noSmithyDocumentSerde
}
// Details about a function's configuration.
type CreateFunctionOutput struct {
// The SHA256 hash of the function's deployment package.
CodeSha256 *string
// The size of the function's deployment package, in bytes.
CodeSize int64
// The function's dead letter queue.
DeadLetterConfig *types.DeadLetterConfig
// The function's description.
Description *string
// The function's environment variables
// (https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html).
Environment *types.EnvironmentResponse
// Connection settings for an Amazon EFS file system
// (https://docs.aws.amazon.com/lambda/latest/dg/configuration-filesystem.html).
FileSystemConfigs []types.FileSystemConfig
// The function's Amazon Resource Name (ARN).
FunctionArn *string
// The name of the function.
FunctionName *string
// The function that Lambda calls to begin executing your function.
Handler *string
// The function's image configuration values.
ImageConfigResponse *types.ImageConfigResponse
// The KMS key that's used to encrypt the function's environment variables. This
// key is only returned if you've configured a customer managed CMK.
KMSKeyArn *string
// The date and time that the function was last updated, in ISO-8601 format
// (https://www.w3.org/TR/NOTE-datetime) (YYYY-MM-DDThh:mm:ss.sTZD).
LastModified *string
// The status of the last update that was performed on the function. This is first
// set to Successful after function creation completes.
LastUpdateStatus types.LastUpdateStatus
// The reason for the last update that was performed on the function.
LastUpdateStatusReason *string
// The reason code for the last update that was performed on the function.
LastUpdateStatusReasonCode types.LastUpdateStatusReasonCode
// The function's layers
// (https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html).
Layers []types.Layer
// For Lambda@Edge functions, the ARN of the master function.
MasterArn *string
// The amount of memory available to the function at runtime.
MemorySize *int32
// The type of deployment package. Set to Image for container image and set Zip for
// .zip file archive.
PackageType types.PackageType
// The latest updated revision of the function or alias.
RevisionId *string
// The function's execution role.
Role *string
// The runtime environment for the Lambda function.
Runtime types.Runtime
// The ARN of the signing job.
SigningJobArn *string
// The ARN of the signing profile version.
SigningProfileVersionArn *string
// The current state of the function. When the state is Inactive, you can
// reactivate the function by invoking it.
State types.State
// The reason for the function's current state.
StateReason *string
// The reason code for the function's current state. When the code is Creating, you
// can't invoke or modify the function.
StateReasonCode types.StateReasonCode
// The amount of time in seconds that Lambda allows a function to run before
// stopping it.
Timeout *int32
// The function's X-Ray tracing configuration.
TracingConfig *types.TracingConfigResponse
// The version of the Lambda function.
Version *string
// The function's networking configuration.
VpcConfig *types.VpcConfigResponse
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationCreateFunctionMiddlewares(stack *middleware.Stack, options Options) (err error) {
err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateFunction{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateFunction{}, middleware.After)
if err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
return err
}
if err = addRetryMiddlewares(stack, options); err != nil {
return err
}
if err = addHTTPSignerV4Middleware(stack, options); err != nil {
return err
}
if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
return err
}
if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
return err
}
if err = addClientUserAgent(stack); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addOpCreateFunctionValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateFunction(options.Region), middleware.Before); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opCreateFunction(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
SigningName: "lambda",
OperationName: "CreateFunction",
}
}