docs
0
# Function Management
1
2
Comprehensive function lifecycle operations including creation, configuration, updates, and deletion of Lambda functions with support for ZIP packages, container images, and various runtime configurations.
3
4
## Capabilities
5
6
### Function Creation
7
8
Creates a new Lambda function from a deployment package.
9
10
```java { .api }
11
/**
12
* Creates a Lambda function from deployment package (ZIP or container image)
13
* @param request Function creation parameters including code, runtime, handler, and role
14
* @return CreateFunctionResult containing function configuration details
15
* @throws ServiceException if service encounters an error
16
* @throws ResourceConflictException if function with same name exists
17
* @throws InvalidParameterValueException if parameters are invalid
18
*/
19
CreateFunctionResult createFunction(CreateFunctionRequest request);
20
21
public class CreateFunctionRequest {
22
/** Function name (required) - 1-64 characters, pattern: [a-zA-Z0-9-_]+ */
23
private String functionName;
24
/** Function runtime (required) */
25
private Runtime runtime;
26
/** IAM role ARN (required) */
27
private String role;
28
/** Function handler (required for ZIP packages) */
29
private String handler;
30
/** Function code (required) */
31
private FunctionCode code;
32
/** Function description (optional) */
33
private String description;
34
/** Timeout in seconds (optional, default: 3, max: 900) */
35
private Integer timeout;
36
/** Memory size in MB (optional, default: 128, range: 128-10240) */
37
private Integer memorySize;
38
/** Whether to publish version (optional, default: false) */
39
private Boolean publish;
40
/** VPC configuration (optional) */
41
private VpcConfig vpcConfig;
42
/** Dead letter queue configuration (optional) */
43
private DeadLetterConfig deadLetterConfig;
44
/** Environment variables (optional) */
45
private Environment environment;
46
/** KMS key ARN for encryption (optional) */
47
private String kmsKeyArn;
48
/** X-Ray tracing configuration (optional) */
49
private TracingConfig tracingConfig;
50
/** Function tags (optional) */
51
private Map<String, String> tags;
52
/** Function layers (optional) */
53
private List<String> layers;
54
/** File system configurations (optional) */
55
private List<FileSystemConfig> fileSystemConfigs;
56
/** Image configuration for container images (optional) */
57
private ImageConfig imageConfig;
58
/** Code signing config ARN (optional) */
59
private String codeSigningConfigArn;
60
/** Instruction set architecture (optional) */
61
private List<String> architectures;
62
/** Ephemeral storage configuration (optional) */
63
private EphemeralStorage ephemeralStorage;
64
/** Logging configuration (optional) */
65
private LoggingConfig loggingConfig;
66
67
// Standard getters and setters with fluent API
68
public CreateFunctionRequest withFunctionName(String functionName) { ... }
69
public CreateFunctionRequest withRuntime(Runtime runtime) { ... }
70
// ... other fluent setters
71
}
72
73
public class CreateFunctionResult {
74
/** Function name */
75
private String functionName;
76
/** Function ARN */
77
private String functionArn;
78
/** Function runtime */
79
private Runtime runtime;
80
/** IAM role ARN */
81
private String role;
82
/** Function handler */
83
private String handler;
84
/** Code size in bytes */
85
private Long codeSize;
86
/** Function description */
87
private String description;
88
/** Timeout in seconds */
89
private Integer timeout;
90
/** Memory size in MB */
91
private Integer memorySize;
92
/** Last modified timestamp */
93
private String lastModified;
94
/** Code SHA256 hash */
95
private String codeSha256;
96
/** Function version */
97
private String version;
98
/** VPC configuration */
99
private VpcConfigResponse vpcConfig;
100
/** Dead letter queue configuration */
101
private DeadLetterConfig deadLetterConfig;
102
/** Environment variables */
103
private EnvironmentResponse environment;
104
/** KMS key ARN */
105
private String kmsKeyArn;
106
/** X-Ray tracing configuration */
107
private TracingConfigResponse tracingConfig;
108
/** Master ARN (for edge functions) */
109
private String masterArn;
110
/** Revision ID */
111
private String revisionId;
112
/** Function layers */
113
private List<Layer> layers;
114
/** Function state */
115
private State state;
116
/** State reason */
117
private String stateReason;
118
/** State reason code */
119
private StateReasonCode stateReasonCode;
120
/** Last update status */
121
private LastUpdateStatus lastUpdateStatus;
122
/** Last update status reason */
123
private String lastUpdateStatusReason;
124
/** Last update status reason code */
125
private LastUpdateStatusReasonCode lastUpdateStatusReasonCode;
126
/** File system configurations */
127
private List<FileSystemConfig> fileSystemConfigs;
128
/** Package type */
129
private PackageType packageType;
130
/** Image configuration */
131
private ImageConfigResponse imageConfig;
132
/** Signing profile version ARN */
133
private String signingProfileVersionArn;
134
/** Signing job ARN */
135
private String signingJobArn;
136
/** Instruction set architectures */
137
private List<String> architectures;
138
/** Ephemeral storage configuration */
139
private EphemeralStorage ephemeralStorage;
140
/** Logging configuration */
141
private LoggingConfig loggingConfig;
142
143
// Standard getters
144
}
145
```
146
147
### Function Retrieval
148
149
Gets function information including configuration and download link.
150
151
```java { .api }
152
/**
153
* Returns function information with signed download URL (valid 10 minutes)
154
* @param request Function retrieval parameters
155
* @return GetFunctionResult containing function metadata and code location
156
* @throws ServiceException if service encounters an error
157
* @throws ResourceNotFoundException if function doesn't exist
158
*/
159
GetFunctionResult getFunction(GetFunctionRequest request);
160
161
public class GetFunctionRequest {
162
/** Function name, ARN, or qualified ARN (required) */
163
private String functionName;
164
/** Function version or alias (optional, default: $LATEST) */
165
private String qualifier;
166
167
public GetFunctionRequest withFunctionName(String functionName) { ... }
168
public GetFunctionRequest withQualifier(String qualifier) { ... }
169
}
170
171
public class GetFunctionResult {
172
/** Function configuration */
173
private FunctionConfiguration configuration;
174
/** Function code location */
175
private FunctionCodeLocation code;
176
/** Function tags */
177
private Map<String, String> tags;
178
/** Concurrency settings */
179
private Concurrency concurrency;
180
181
// Standard getters
182
}
183
```
184
185
### Function Configuration
186
187
Gets version-specific configuration settings without code information.
188
189
```java { .api }
190
/**
191
* Returns version-specific function configuration metadata
192
* @param request Configuration retrieval parameters
193
* @return GetFunctionConfigurationResult containing function settings
194
* @throws ServiceException if service encounters an error
195
* @throws ResourceNotFoundException if function doesn't exist
196
*/
197
GetFunctionConfigurationResult getFunctionConfiguration(GetFunctionConfigurationRequest request);
198
199
public class GetFunctionConfigurationRequest {
200
/** Function name, ARN, or qualified ARN (required) */
201
private String functionName;
202
/** Function version or alias (optional, default: $LATEST) */
203
private String qualifier;
204
205
public GetFunctionConfigurationRequest withFunctionName(String functionName) { ... }
206
public GetFunctionConfigurationRequest withQualifier(String qualifier) { ... }
207
}
208
209
public class GetFunctionConfigurationResult {
210
/** Function name */
211
private String functionName;
212
/** Function ARN */
213
private String functionArn;
214
/** Function runtime */
215
private Runtime runtime;
216
/** IAM role ARN */
217
private String role;
218
/** Function handler */
219
private String handler;
220
/** Code size in bytes */
221
private Long codeSize;
222
/** Function description */
223
private String description;
224
/** Timeout in seconds */
225
private Integer timeout;
226
/** Memory size in MB */
227
private Integer memorySize;
228
/** Last modified timestamp */
229
private String lastModified;
230
/** Code SHA256 hash */
231
private String codeSha256;
232
/** Function version */
233
private String version;
234
// ... additional configuration fields same as CreateFunctionResult
235
}
236
```
237
238
### Function Code Updates
239
240
Updates function code for ZIP or container image packages.
241
242
```java { .api }
243
/**
244
* Updates function code with new deployment package
245
* @param request Code update parameters
246
* @return UpdateFunctionCodeResult containing updated function configuration
247
* @throws ServiceException if service encounters an error
248
* @throws ResourceNotFoundException if function doesn't exist
249
* @throws InvalidParameterValueException if parameters are invalid
250
* @throws ResourceConflictException if function is being modified
251
*/
252
UpdateFunctionCodeResult updateFunctionCode(UpdateFunctionCodeRequest request);
253
254
public class UpdateFunctionCodeRequest {
255
/** Function name (required) */
256
private String functionName;
257
/** ZIP file content (base64 encoded, max 50MB) */
258
private String zipFile;
259
/** S3 bucket name */
260
private String s3Bucket;
261
/** S3 object key */
262
private String s3Key;
263
/** S3 object version */
264
private String s3ObjectVersion;
265
/** Container image URI */
266
private String imageUri;
267
/** Whether to publish new version (optional, default: false) */
268
private Boolean publish;
269
/** Whether to perform dry run (optional, default: false) */
270
private Boolean dryRun;
271
/** Expected revision ID for conditional update (optional) */
272
private String revisionId;
273
/** Instruction set architectures (optional) */
274
private List<String> architectures;
275
276
public UpdateFunctionCodeRequest withFunctionName(String functionName) { ... }
277
public UpdateFunctionCodeRequest withZipFile(String zipFile) { ... }
278
public UpdateFunctionCodeRequest withS3Bucket(String s3Bucket) { ... }
279
// ... other fluent setters
280
}
281
282
public class UpdateFunctionCodeResult {
283
// Same fields as CreateFunctionResult
284
private String functionName;
285
private String functionArn;
286
private Runtime runtime;
287
// ... all configuration fields
288
}
289
```
290
291
### Function Configuration Updates
292
293
Modifies version-specific function settings.
294
295
```java { .api }
296
/**
297
* Updates function configuration settings (not code)
298
* @param request Configuration update parameters
299
* @return UpdateFunctionConfigurationResult with updated settings
300
* @throws ServiceException if service encounters an error
301
* @throws ResourceNotFoundException if function doesn't exist
302
* @throws InvalidParameterValueException if parameters are invalid
303
* @throws ResourceConflictException if function is being modified
304
*/
305
UpdateFunctionConfigurationResult updateFunctionConfiguration(UpdateFunctionConfigurationRequest request);
306
307
public class UpdateFunctionConfigurationRequest {
308
/** Function name (required) */
309
private String functionName;
310
/** IAM role ARN (optional) */
311
private String role;
312
/** Function handler (optional) */
313
private String handler;
314
/** Function description (optional) */
315
private String description;
316
/** Timeout in seconds (optional, range: 1-900) */
317
private Integer timeout;
318
/** Memory size in MB (optional, range: 128-10240) */
319
private Integer memorySize;
320
/** VPC configuration (optional) */
321
private VpcConfig vpcConfig;
322
/** Environment variables (optional) */
323
private Environment environment;
324
/** Function runtime (optional) */
325
private Runtime runtime;
326
/** Dead letter queue configuration (optional) */
327
private DeadLetterConfig deadLetterConfig;
328
/** KMS key ARN (optional) */
329
private String kmsKeyArn;
330
/** X-Ray tracing configuration (optional) */
331
private TracingConfig tracingConfig;
332
/** Expected revision ID for conditional update (optional) */
333
private String revisionId;
334
/** Function layers (optional) */
335
private List<String> layers;
336
/** File system configurations (optional) */
337
private List<FileSystemConfig> fileSystemConfigs;
338
/** Image configuration (optional) */
339
private ImageConfig imageConfig;
340
/** Ephemeral storage configuration (optional) */
341
private EphemeralStorage ephemeralStorage;
342
/** Logging configuration (optional) */
343
private LoggingConfig loggingConfig;
344
345
public UpdateFunctionConfigurationRequest withFunctionName(String functionName) { ... }
346
public UpdateFunctionConfigurationRequest withRole(String role) { ... }
347
// ... other fluent setters
348
}
349
350
public class UpdateFunctionConfigurationResult {
351
// Same fields as CreateFunctionResult
352
private String functionName;
353
private String functionArn;
354
// ... all configuration fields
355
}
356
```
357
358
### Function Deletion
359
360
Deletes function including all versions and aliases.
361
362
```java { .api }
363
/**
364
* Deletes Lambda function, all versions, and aliases
365
* @param request Function deletion parameters
366
* @return DeleteFunctionResult (empty response)
367
* @throws ServiceException if service encounters an error
368
* @throws ResourceNotFoundException if function doesn't exist
369
* @throws InvalidParameterValueException if parameters are invalid
370
* @throws ResourceConflictException if function is being modified
371
*/
372
DeleteFunctionResult deleteFunction(DeleteFunctionRequest request);
373
374
public class DeleteFunctionRequest {
375
/** Function name (required) */
376
private String functionName;
377
/** Function version or alias (optional, deletes specific version if provided) */
378
private String qualifier;
379
380
public DeleteFunctionRequest withFunctionName(String functionName) { ... }
381
public DeleteFunctionRequest withQualifier(String qualifier) { ... }
382
}
383
384
public class DeleteFunctionResult {
385
// Empty response
386
}
387
```
388
389
### Function Listing
390
391
Lists Lambda functions with pagination support.
392
393
```java { .api }
394
/**
395
* Lists Lambda functions (up to 50 per call)
396
* @param request Function listing parameters
397
* @return ListFunctionsResult containing function list and pagination token
398
* @throws ServiceException if service encounters an error
399
* @throws InvalidParameterValueException if parameters are invalid
400
*/
401
ListFunctionsResult listFunctions(ListFunctionsRequest request);
402
403
/**
404
* Lists all Lambda functions with default parameters
405
* @return ListFunctionsResult containing function list
406
*/
407
ListFunctionsResult listFunctions();
408
409
public class ListFunctionsRequest {
410
/** ARN of master function (for edge functions, optional) */
411
private String masterRegion;
412
/** Function version filter (optional, values: ALL) */
413
private String functionVersion;
414
/** Pagination token from previous call (optional) */
415
private String marker;
416
/** Maximum functions to return (optional, range: 1-50, default: 50) */
417
private Integer maxItems;
418
419
public ListFunctionsRequest withMasterRegion(String masterRegion) { ... }
420
public ListFunctionsRequest withFunctionVersion(String functionVersion) { ... }
421
// ... other fluent setters
422
}
423
424
public class ListFunctionsResult {
425
/** Next pagination token (null if no more results) */
426
private String nextMarker;
427
/** List of function configurations */
428
private List<FunctionConfiguration> functions;
429
430
// Standard getters
431
}
432
```
433
434
**Usage Examples:**
435
436
```java
437
import com.amazonaws.services.lambda.*;
438
import com.amazonaws.services.lambda.model.*;
439
import java.nio.ByteBuffer;
440
import java.util.Base64;
441
442
// Create client
443
AWSLambda lambdaClient = AWSLambdaClientBuilder.defaultClient();
444
445
// Create function from ZIP file
446
byte[] zipContent = // ... load ZIP file bytes
447
CreateFunctionRequest createRequest = new CreateFunctionRequest()
448
.withFunctionName("my-java-function")
449
.withRuntime(Runtime.java11)
450
.withRole("arn:aws:iam::123456789012:role/lambda-execution-role")
451
.withHandler("com.example.MyHandler::handleRequest")
452
.withCode(new FunctionCode().withZipFile(ByteBuffer.wrap(zipContent)))
453
.withDescription("My Java Lambda function")
454
.withTimeout(30)
455
.withMemorySize(512)
456
.withEnvironment(new Environment()
457
.addVariablesEntry("ENV", "production")
458
.addVariablesEntry("LOG_LEVEL", "INFO"));
459
460
CreateFunctionResult createResult = lambdaClient.createFunction(createRequest);
461
System.out.println("Created function: " + createResult.getFunctionArn());
462
463
// Update function code from S3
464
UpdateFunctionCodeRequest updateCodeRequest = new UpdateFunctionCodeRequest()
465
.withFunctionName("my-java-function")
466
.withS3Bucket("my-lambda-bucket")
467
.withS3Key("my-function-v2.zip")
468
.withPublish(true);
469
470
UpdateFunctionCodeResult updateResult = lambdaClient.updateFunctionCode(updateCodeRequest);
471
System.out.println("Updated to version: " + updateResult.getVersion());
472
473
// Update function configuration
474
UpdateFunctionConfigurationRequest updateConfigRequest = new UpdateFunctionConfigurationRequest()
475
.withFunctionName("my-java-function")
476
.withTimeout(60)
477
.withMemorySize(1024)
478
.withEnvironment(new Environment()
479
.addVariablesEntry("ENV", "production")
480
.addVariablesEntry("LOG_LEVEL", "DEBUG"));
481
482
UpdateFunctionConfigurationResult configResult = lambdaClient.updateFunctionConfiguration(updateConfigRequest);
483
484
// Get function information
485
GetFunctionRequest getRequest = new GetFunctionRequest()
486
.withFunctionName("my-java-function");
487
GetFunctionResult getResult = lambdaClient.getFunction(getRequest);
488
System.out.println("Function state: " + getResult.getConfiguration().getState());
489
490
// List all functions
491
ListFunctionsResult listResult = lambdaClient.listFunctions();
492
for (FunctionConfiguration func : listResult.getFunctions()) {
493
System.out.println(func.getFunctionName() + " - " + func.getRuntime());
494
}
495
496
// Delete function
497
DeleteFunctionRequest deleteRequest = new DeleteFunctionRequest()
498
.withFunctionName("my-java-function");
499
lambdaClient.deleteFunction(deleteRequest);
500
```