Details
| ID | AWS - Lambda |
|---|---|
| Provider | Amazon |
| Category | IT Services |
| From Version | 6.8.0 |
| Docker Image | demisto/boto3py3:1.0.0.10221838 |
| Supported Modules | Agentix XSIAM |
README
Amazon Web Services Serverless Compute service (lambda)
This integration was integrated and tested with version 2015-03-31 of AWS - Lambda.
For detailed instructions about setting up authentication, see: AWS Integrations - Authentication.
Required AWS IAM Permissions and Roles for Lambda are documented here.
Configure AWS - Lambda in Cortex
| Parameter | Description | Required |
|---|---|---|
| AWS Default Region | True | |
| Role Arn | False | |
| Role Session Name | False | |
| Role Session Duration | False | |
| Access Key | False | |
| Secret Key | False | |
| Access Key | False | |
| Secret Key | False | |
| Timeout | The time in seconds till a timeout exception is reached. You can specify just the read timeout (for example 60) or also the connect timeout followed after a comma (for example 60,10). If a connect timeout is not specified, a default of 10 seconds will be used. You may also override the value at the aws-lambda-invoke command. | False |
| Retries | The maximum number of retry attempts when connection or throttling errors are encountered. Set to 0 to disable retries. The default value is 5 and the limit is 10. Note: Increasing the number of retries will increase the execution time. You may also override the value when executing the aws-lambda-invoke command. | False |
| PrivateLink service URL. | False | |
| STS PrivateLink URL | False | |
| AWS STS Regional Endpoints | Sets the AWS_STS_REGIONAL_ENDPOINTS environment variable to specify the AWS STS endpoint resolution logic. By default, this option is set to “legacy” in AWS. Leave empty if the environment variable is already set using server configuration. | False |
| Trust any certificate (not secure) | False | |
| Use system proxy settings | False |
Commands
You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.
aws-lambda-get-function
Returns the configuration information of the Lambda function and a presigned URL link to the .zip file you uploaded with CreateFunction so you can download the .zip file. Note that the URL is valid for up to 10 minutes. The configuration information is the same information you provided as parameters when uploading the function. Use the Qualifier parameter to retrieve a published version of the function. Otherwise, returns the unpublished version ($LATEST ).
Required Permissions
AWSLambda_ReadOnlyAccess: more details here.
Base Command
aws-lambda-get-function
Input
| Argument Name | Description | Required |
|---|---|---|
| functionName | The name of the Lambda function. | Required |
| qualifier | Specify a version or alias to get details about a published version of the function. | Optional |
| region | The AWS Region, if not specified the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.Functions.Configuration.FunctionName | string | The name of the function. |
| AWS.Lambda.Functions.Configuration.FunctionArn | string | The function’s Amazon Resource Name. |
| AWS.Lambda.Functions.Configuration.Runtime | string | The runtime environment for the Lambda function. |
| AWS.Lambda.Functions.Configuration.Role | string | The function’s execution role. |
| AWS.Lambda.Functions.Configuration.Handler | string | The function Lambda calls to begin executing your function. |
| AWS.Lambda.Functions.Configuration.CodeSize | string | The size of the function’s deployment package in bytes. |
| AWS.Lambda.Functions.Configuration.Description | string | The function’s description. |
| AWS.Lambda.Functions.Configuration.Timeout | number | The amount of time that Lambda allows a function to run before terminating it. |
| AWS.Lambda.Functions.Configuration.MemorySize | number | The memory allocated to the function |
| AWS.Lambda.Functions.Configuration.LastModified | date | The date and time that the function was last updated, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD). |
| AWS.Lambda.Functions.Configuration.CodeSha256 | string | The SHA256 hash of the function’s deployment package. |
| AWS.Lambda.Functions.Configuration.Version | string | The version of the Lambda function. |
| AWS.Lambda.Functions.Configuration.VpcConfig.SubnetIds | string | A list of VPC subnet IDs. |
| AWS.Lambda.Functions.Configuration.VpcConfig.SecurityGroupIds | string | A list of VPC security groups IDs. |
| AWS.Lambda.Functions.Configuration.VpcConfig.VpcId | string | The ID of the VPC. |
| AWS.Lambda.Functions.Configuration.DeadLetterConfig.TargetArn | string | The Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic. |
| AWS.Lambda.Functions.Configuration.Environment.Variables | string | Environment variable key-value pairs. |
| AWS.Lambda.Functions.Configuration.Environment.Error.ErrorCode | string | The error code for environment variables that could not be applied. |
| AWS.Lambda.Functions.Configuration.Environment.Error.Message | string | The error message for environment variables that could not be applied. |
| AWS.Lambda.Functions.Configuration.KMSKeyArn | string | The KMS key used to encrypt the function’s environment variables. Only returned if you’ve configured a customer managed CMK. |
| AWS.Lambda.Functions.Configuration.TracingConfig.Mode | string | The function’s AWS X-Ray tracing configuration. The tracing mode. |
| AWS.Lambda.Functions.Configuration.MasterArn | string | The ARN of the master function. |
| AWS.Lambda.Functions.Configuration.RevisionId | string | Represents the latest updated revision of the function or alias. |
| AWS.Lambda.Functions.Configuration.Layers.Arn | string | The Amazon Resource Name (ARN) of the function layer. |
| AWS.Lambda.Functions.Configuration.Layers.CodeSize | number | The size of the layer archive in bytes. |
| AWS.Lambda.Functions.Code.RepositoryType | string | The repository from which you can download the function. |
| AWS.Lambda.Functions.Code.Location | string | The presigned URL you can use to download the function’s .zip file that you previously uploaded. The URL is valid for up to 10 minutes. |
| AWS.Lambda.Functions.Tags | string | list of tags associated with the function. |
| AWS.Lambda.Functions.Concurrency.ReservedConcurrentExecutions | string | The number of concurrent executions reserved for this function. |
Command Example
!aws-lambda-get-function functionName="test_echo"
Context Example
{
"AWS": {
"Lambda": {
"Functions": {
"Code": {
"Location": "https://awslambda-us-west-2-tasks.s3.us-west-2.amazonaws.com/snapshots/123456789012/test_echo-f4e5b684-10bb-4341-9701-2ec77a3a9455?versionId=EkrCKdR3NiLj4WMGnl4FW7Emnp2LwVj9&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEAkaCXVzLXdlc3QtMiJGMEQCIB97MBosyyMTyFoHXZWE7%2FSLrXNfaxPkqt9JvcPaKCQSAiAedNNcQXK%2B1dKV7bMOjfza9DxC9XTPnuyVauIb0kWeTCq9AwjC%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAMaDDUwMjI5NzA3NjE2MyIMWFyriTbErPSEhGT7KpEDpyrzGUskWDr%2BghzqocY6ZUY%2BWEdDvKrEyUP8CdQFw2SSmn4vXxhFBocUkayPWdpj%2Bxj%2BcjrBh4vHwo5b9GmMJE36omzIiDIyIPcNiBDViHN%2FoaG3YLsDkOxhdLw%2BdB4Z80QwcO61YUXQtFV5CNLmMpCbqNhZ8W%2By0M1nr6ZuEX3NThpWC0e%2BdSPcKzTqTVGo8SjeOMxYeZu5d%2BLkkG1a0wIfxjrYbf1LBIsOdewkNyQa5crt7NEs7ZbFqKe21%2F5v%2BmJudanK6M76U84GRVR0KiRY%2FDuYnFzGWTvi8pWwHvi85tiAd32Nx5SQiqim97hwv53kyyXnkFSIasT76yzQEuRsVlS6TSsMKW8FOOwRwj0ho5a9cPuC5lY0OlAjmJX2r8ruoFJqifDxNjPlErjYe2AvCSIf6Hb28J1RcUC6k%2FS2QC1Y%2Foiy8qWXah8ssDwQXVtmFTtDq8KC1KDXPVOL75zN4wyT7mW18GXXR3%2BAY40U1Rt%2FZsWoqqeb7qkDGevzaLJ1BeOSo53BbQDRC8DxCSkww9PC%2FwU67AFLZ6OqozcNsNierzQTWiHEtk89qOcU8q6glYLPr9kqhS4Hqh7Qbt1tytfGRUHoRiF4vYDYa1oQtEY%2BuG3qvyWTQogSsXUrt%2BvjeOp47uvaGrzUnMfQllgGHgvei2KeOvxQQl4dRuYdhelWbIXFB6HYtnTQ8BvEW401tkgNh41OEw%2F2w7BYBPee3K16MeyLJDlb2eO0Qpe4isP%2BtJgQQRofapkYAkasB7li5Tw8E0EP%2BB5Vi2YT0Dc0Uer6ltKBwuixPJtA6Ul6h6Epcyu61gka8FHsFxjxAMh0d%2B9xZJU5yfiFIm6FE1yo4WbZAQ%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20210102T175325Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Credential=ASIAXJ4Z5EHB73ALY3PB%2F20210102%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=80ef02ae7c589f7c11b2132ad3198ac43c8bbfa64951728f02693cb81b01a494",
"RepositoryType": "S3"
},
"Configuration": {
"CodeSha256": "nhHf3duE8nsbpBFqk1jH/7FrnOwOTXxpjwJJW5IWRDw=",
"CodeSize": 394,
"Description": "",
"FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:test_echo",
"FunctionName": "test_echo",
"Handler": "handler.test_echo",
"LastModified": "2020-12-31T09:12:56.676+0000",
"LastUpdateStatus": "Successful",
"MemorySize": 128,
"PackageType": "Zip",
"RevisionId": "d501879f-a589-44fa-92d2-7a984601e289",
"Role": "arn:aws:iam::123456789012:role/serverlessrepo-magic-8-ball-Magic8BallRole-11JS8GYNU5JM1",
"Runtime": "nodejs12.x",
"State": "Active",
"Timeout": 3,
"TracingConfig": {
"Mode": "PassThrough"
},
"Version": "$LATEST"
},
"Region": "us-west-2",
"ResponseMetadata": {
"HTTPHeaders": {
"connection": "keep-alive",
"content-length": "2642",
"content-type": "application/json",
"date": "Sat, 02 Jan 2021 17:53:25 GMT",
"x-amzn-requestid": "dfbe644c-b2bd-45ae-bb75-d6356c25041b"
},
"HTTPStatusCode": 200,
"RequestId": "dfbe644c-b2bd-45ae-bb75-d6356c25041b",
"RetryAttempts": 0
}
}
}
}
}
Human Readable Output
AWS Lambda Functions
FunctionArn FunctionName Region Runtime arn:aws:lambda:us-west-2:123456789012:function:test_echo test_echo us-west-2 nodejs12.x
aws-lambda-list-functions
Returns a list of your Lambda functions. For each function, the response includes the function configuration information. You must use GetFunction to retrieve the code for your function.
Required Permissions
AWSLambda_ReadOnlyAccess: more details here.
Base Command
aws-lambda-list-functions
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region, if not specified the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.Functions.FunctionName | string | The name of the function. |
| AWS.Lambda.Functions.FunctionArn | string | The function’s Amazon Resource Name. |
| AWS.Lambda.Functions.Runtime | string | The runtime environment for the Lambda function. |
| AWS.Lambda.Functions.Role | string | The function’s execution role. |
| AWS.Lambda.Functions.Handler | string | The function Lambda calls to begin executing your function. |
| AWS.Lambda.Functions.CodeSize | number | The size of the function’s deployment package in bytes. |
| AWS.Lambda.Functions.Description | string | The function’s description. |
| AWS.Lambda.Functions.Timeout | number | The amount of time that Lambda allows a function to run before terminating it. |
| AWS.Lambda.Functions.MemorySize | number | The memory allocated to the function. |
| AWS.Lambda.Functions.LastModified | date | The date and time that the function was last updated, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD). |
| AWS.Lambda.Functions.CodeSha256 | string | The SHA256 hash of the function’s deployment package. |
| AWS.Lambda.Functions.Version | string | The version of the Lambda function. |
| AWS.Lambda.Functions.VpcConfig.SubnetIds | string | A list of VPC subnet IDs. |
| AWS.Lambda.Functions.VpcConfig.SecurityGroupIds | string | A list of VPC security groups IDs. |
| AWS.Lambda.Functions.VpcConfig.VpcId | string | The ID of the VPC. |
| AWS.Lambda.Functions.DeadLetterConfig.TargetArn | string | The Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic. |
| AWS.Lambda.Functions.Environment.Variables | string | Environment variable key-value pairs. |
| AWS.Lambda.Functions.Environment.Error.ErrorCode | string | Error messages for environment variables that could not be applied. The error code. |
| AWS.Lambda.Functions.Environment.Error.Message | string | Error messages for environment variables that could not be applied. The error message. |
| AWS.Lambda.Functions.KMSKeyArn | string | The KMS key used to encrypt the function’s environment variables. Only returned if you’ve configured a customer managed CMK. |
| AWS.Lambda.Functions.TracingConfig.Mode | string | The function’s AWS X-Ray tracing configuration. The tracing mode. |
| AWS.Lambda.Functions.MasterArn | string | The ARN of the master function. |
| AWS.Lambda.Functions.RevisionId | string | Represents the latest updated revision of the function or alias. |
| AWS.Lambda.Functions.Layers.Arn | string | The Amazon Resource Name (ARN) of the function layer. |
| AWS.Lambda.Functions.Layers.CodeSize | string | The size of the layer archive in bytes. |
Command Example
#### Context Example
```json
{
"AWS": {
"Lambda": {
"Functions": {
"Functions": [
{
"CodeSha256": "oP52F3PYjPdGbkzKpA3yjmjQj1AmoujE5LjEu4V6It0=",
"CodeSize": 370,
"Description": "",
"FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:test_sleep",
"FunctionName": "test_sleep",
"Handler": "handler.test_sleep",
"LastModified": "2020-12-30T16:15:55.726+0000",
"MemorySize": 128,
"PackageType": "Zip",
"RevisionId": "a5094b27-e339-4362-bb69-c82c1fde4376",
"Role": "arn:aws:iam::123456789012:role/serverlessrepo-magic-8-ball-Magic8BallRole-11JS8GYNU5JM1",
"Runtime": "nodejs12.x",
"Timeout": 180,
"TracingConfig": {
"Mode": "PassThrough"
},
"Version": "$LATEST"
},
{
"CodeSha256": "nhHf3duE8nsbpBFqk1jH/7FrnOwOTXxpjwJJW5IWRDw=",
"CodeSize": 394,
"Description": "",
"FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:test_echo",
"FunctionName": "test_echo",
"Handler": "handler.test_echo",
"LastModified": "2020-12-31T09:12:56.676+0000",
"MemorySize": 128,
"PackageType": "Zip",
"RevisionId": "d501879f-a589-44fa-92d2-7a984601e289",
"Role": "arn:aws:iam::123456789012:role/serverlessrepo-magic-8-ball-Magic8BallRole-11JS8GYNU5JM1",
"Runtime": "nodejs12.x",
"Timeout": 3,
"TracingConfig": {
"Mode": "PassThrough"
},
"Version": "$LATEST"
},
{
"CodeSha256": "yUnb5Nsw5KQzQGj0EBR2meRebGpDy3VuYjNPFA1PsNw=",
"CodeSize": 271667,
"Description": "",
"FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:testingFunction",
"FunctionName": "testingFunction",
"Handler": "index.handler",
"LastModified": "2019-02-20T15:33:28.335+0000",
"MemorySize": 128,
"PackageType": "Zip",
"RevisionId": "08674053-884d-4a08-8803-a92374b84386",
"Role": "arn:aws:iam::123456789012:role/service-role/testingRoleLambda",
"Runtime": "nodejs8.10",
"Timeout": 3,
"TracingConfig": {
"Mode": "PassThrough"
},
"Version": "$LATEST"
}
],
"Region": "us-west-2",
"ResponseMetadata": {
"HTTPHeaders": {
"connection": "keep-alive",
"content-length": "2741",
"content-type": "application/json",
"date": "Sat, 02 Jan 2021 17:53:23 GMT",
"x-amzn-requestid": "5c5115b5-22fa-4f1a-a981-04847a54fe58"
},
"HTTPStatusCode": 200,
"RequestId": "5c5115b5-22fa-4f1a-a981-04847a54fe58",
"RetryAttempts": 0
}
}
}
}
}
Human Readable Output
AWS Lambda Functions
FunctionArn FunctionName LastModified Region Runtime arn:aws:lambda:us-west-2:123456789012:function:test_sleep test_sleep 2020-12-30T16:15:55.726+0000 us-west-2 nodejs12.x arn:aws:lambda:us-west-2:123456789012:function:test_echo test_echo 2020-12-31T09:12:56.676+0000 us-west-2 nodejs12.x arn:aws:lambda:us-west-2:123456789012:function:testingFunction testingFunction 2019-02-20T15:33:28.335+0000 us-west-2 nodejs8.10
aws-lambda-list-aliases
Returns list of aliases created for a Lambda function. For each alias, the response includes information such as the alias ARN, description, alias name, and the function version to which it points.
Required Permissions
AWSLambda_ReadOnlyAccess: more details here.
Base Command
aws-lambda-list-aliases
Input
| Argument Name | Description | Required |
|---|---|---|
| functionName | The name of the lambda function. | Required |
| functionVersion | If you specify this optional parameter, the API returns only the aliases that are pointing to the specific Lambda function version, otherwise the API returns all of the aliases created for the Lambda function. | Optional |
| region | The AWS Region, if not specified the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.Aliases.AliasArn | string | Lambda function ARN that is qualified using the alias name as the suffix. |
| AWS.Lambda.Aliases.Name | string | Alias name. |
| AWS.Lambda.Aliases.FunctionVersion | string | Function version to which the alias points. |
| AWS.Lambda.Aliases.Description | string | Alias description. |
| AWS.Lambda.Aliases.RoutingConfig.AdditionalVersionWeights | string | The name of the second alias, and the percentage of traffic that is routed to it. |
| AWS.Lambda.Aliases.RevisionId | string | Represents the latest updated revision of the function or alias. |
aws-lambda-invoke
Invokes a Lambda function. Specify just a function name to invoke the latest version of the function. To invoke a published version, use the Qualifier parameter to specify a version or alias. If you use the RequestResponse (synchronous) invocation option, note that the function may be invoked multiple times if a timeout is reached. For functions with a long timeout, your client may be disconnected during synchronous invocation while it waits for a response. Use the “timeout” and “retries” arguments to control this behavior. If you use the Event (asynchronous) invocation option, the function will be invoked at least once in response to an event and the function must be idempotent to handle this.
Required Permissions
AWSLambdaRole: more details here.
Base Command
aws-lambda-invoke
Input
| Argument Name | Description | Required |
|---|---|---|
| functionName | The name of the Lambda function. | Required |
| invocationType | Choose from the following options. RequestResponse (default) - Invoke the function synchronously. Keep the connection open until the function returns a response or times out. Event - Invoke the function asynchronously. Send events that fail multiple times to the function’s dead-letter queue (if configured). DryRun - Validate parameter values and verify that the user or role has permission to invoke the function. Possible values are: Event, RequestResponse, DryRun. | Optional |
| logType | You can set this optional parameter to Tail in the request only if you specify the InvocationType parameter with value RequestResponse . In this case, AWS Lambda returns the base64-encoded last 4 KB of log data produced by your Lambda function in the x-amz-log-result header. Possible values are: None, Tail. | Optional |
| clientContext | Using the ClientContext you can pass client-specific information to the Lambda function you are invoking. | Optional |
| payload | JSON that you want to provide to your Lambda function as input. | Optional |
| qualifier | Specify a version or alias to invoke a published version of the function. | Optional |
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
| retries | The maximum retry attempts when connection or throttling errors are encountered. Set to 0 to disable retries. If not specified, will use the instances configured default timeout. | Optional |
| timeout | The time in seconds till a timeout exception is reached. You can specify just the read timeout (for example 60) or also the connect timeout followed after a comma (for example 60,10). If not specified, will use the instances configured default timeout. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.InvokedFunctions.FunctionName | string | The name of the Lambda function. |
| AWS.Lambda.InvokedFunctions.FunctionError | string | Indicates whether an error occurred while executing the Lambda function. If an error occurred this field will have one of two values; Handled or Unhandled. Handled errors are errors that are reported by the function while the Unhandled errors are those detected and reported by AWS Lambda. Unhandled errors include out of memory errors and function timeouts. |
| AWS.Lambda.InvokedFunctions.LogResult | string | Logs for the Lambda function invocation. This is present only if the invocation type is RequestResponse and the logs were requested. |
| AWS.Lambda.InvokedFunctions.Payload | string | The JSON representation of the object returned by the Lambda function. This is present only if the invocation type is RequestResponse. |
| AWS.Lambda.InvokedFunctions.ExecutedVersion | string | The function version that has been executed. This value is returned only if the invocation type is RequestResponse. |
| AWS.Lambda.InvokedFunctions.Region | string | The AWS Region. |
| AWS.Lambda.InvokedFunctions.RequestPayload | unknown | The JSON representation of the object passed to the Lambda function as input. |
Command Example
!aws-lambda-invoke functionName="test_echo" logType="Tail" payload="{\"value\":\"test\"}"
Context Example
{
"AWS": {
"Lambda": {
"InvokedFunctions": {
"ExecutedVersion": "$LATEST",
"FunctionName": "test_echo",
"LogResult": "START RequestId: c24e087f-5c05-4e92-a1a8-e54f2d6cd925 Version: $LATEST\nEND RequestId: c24e087f-5c05-4e92-a1a8-e54f2d6cd925\nREPORT RequestId: c24e087f-5c05-4e92-a1a8-e54f2d6cd925\tDuration: 16.00 ms\tBilled Duration: 16 ms\tMemory Size: 128 MB\tMax Memory Used: 65 MB\tInit Duration: 133.86 ms\t\n",
"Payload": "{\"message\":\"Your function executed successfully!\",\"payload\":{\"value\":\"test\"}}",
"Region": "us-west-2"
}
}
}
}
Human Readable Output
AWS Lambda Invoked Functions
ExecutedVersion FunctionName LogResult Payload Region $LATEST test_echo START RequestId: c24e087f-5c05-4e92-a1a8-e54f2d6cd925 Version: $LATEST
END RequestId: c24e087f-5c05-4e92-a1a8-e54f2d6cd925
REPORT RequestId: c24e087f-5c05-4e92-a1a8-e54f2d6cd925 Duration: 16.00 ms Billed Duration: 16 ms Memory Size: 128 MB Max Memory Used: 65 MB Init Duration: 133.86 ms{“message”:”Your function executed successfully!”,”payload”:{“value”:”test”}} us-west-2
aws-lambda-get-account-settings
Retrieves details about your account’s limits and usage in an AWS Region.
Required Permissions
AWSLambda_ReadOnlyAccess: more details here.
Base Command
aws-lambda-get-account-settings
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.AccountLimit.TotalCodeSize | number | The amount of storage space that you can use for all deployment packages and layer archives. |
| AWS.Lambda.AccountLimit.CodeSizeUnzipped | number | The maximum size of your function’s code and layers when they’re extracted. |
| AWS.Lambda.AccountLimit.CodeSizeZipped | number | The maximum size of a deployment package when it’s uploaded directly to AWS Lambda. Use Amazon S3 for larger files. |
| AWS.Lambda.AccountLimit.ConcurrentExecutions | number | The maximum number of simultaneous function executions. |
| AWS.Lambda.AccountLimit.UnreservedConcurrentExecutions | number | The maximum number of simultaneous function executions, minus the capacity that’s reserved for individual functions with PutFunctionConcurrency . |
| AWS.Lambda.AccountUsage.TotalCodeSize | number | The amount of storage space, in bytes, that’s being used by deployment packages and layer archives. |
| AWS.Lambda.AccountUsage. FunctionCount | number | The number of Lambda functions. |
Command Example
#### Context Example
```json
{
"AWS": {
"Lambda": {
"Functions": {
"AccountLimit": {
"CodeSizeUnzipped": 262144000,
"CodeSizeZipped": 52428800,
"ConcurrentExecutions": 1000,
"TotalCodeSize": 80530636800,
"UnreservedConcurrentExecutions": 1000
},
"AccountUsage": {
"FunctionCount": 3,
"TotalCodeSize": 272431
},
"Region": "us-west-2",
"ResponseMetadata": {
"HTTPHeaders": {
"connection": "keep-alive",
"content-length": "393",
"content-type": "application/json",
"date": "Sat, 02 Jan 2021 17:53:27 GMT",
"x-amzn-requestid": "2030cf7b-b4f7-4f57-b13b-1572cdaa3286"
},
"HTTPStatusCode": 200,
"RequestId": "2030cf7b-b4f7-4f57-b13b-1572cdaa3286",
"RetryAttempts": 0
}
}
}
}
}
Human Readable Output
AWS Lambda Functions
AccountLimit AccountUsage TotalCodeSize: 80530636800
CodeSizeUnzipped: 262144000
CodeSizeZipped: 52428800
ConcurrentExecutions: 1000
UnreservedConcurrentExecutions: 1000TotalCodeSize: 272431
FunctionCount: 3
aws-lambda-get-policy
Returns the resource-based IAM policy for a function, version, or alias.
Base Command
aws-lambda-get-policy
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
| functionName | The name of the Lambda function, version, or alias. You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.Policy.Version | String | The version of the policy. |
| AWS.Lambda.Policy.Id | String | The ID of the policy. |
| AWS.Lambda.Policy.Statement.Sid | String | The statement ID within the policy. |
| AWS.Lambda.Policy.Statement.Effect | String | The effect (allow/deny) specified in the policy statement. |
| AWS.Lambda.Policy.Statement.Principal.AWS | String | The AWS principal ARN specified in the AWS Lambda policy statement. |
| AWS.Lambda.Policy.Statement.Action | String | The action specified in the AWS Lambda policy statement. |
| AWS.Lambda.Policy.Statement.Resource | String | The resource ARN specified in the AWS Lambda policy statement. |
| AWS.Lambda.RevisionId | String | A unique identifier for the current revision of the policy. |
Command example
!aws-lambda-get-policy functionName="test"
Context Example
{
"AWS": {
"Lambda": {
"Policy": {
"Id": "default",
"Statement": [
{
"Action": "lambda",
"Condition": {
"ArnLike": {
"AWS:SourceArn": "arn:aws:dummy-api:dummy:12345678:dummy/*/*/test"
}
},
"Effect": "Allow",
"Principal": {
"Service": "apidummy.dummy.com"
},
"Resource": "arn:aws:dummy-api:dummy:12345678:dummy/*/*/test",
"Sid": "lambda-1111-1111-1111-1111-1111"
}
],
"Version": "2012-10-17"
},
"RevisionId": "1111-1111-111-111-11111"
}
}
}
Human Readable Output
Policy
Action Effect Id Resource RevisionId Sid Version Principal lambda Allow default arn:aws:dummy-api:dummy:12345678:dummy///test 1111-1111-111-111-11111 arn:aws:dummy-api:dummy:12345678:dummy///test 2015-10-17 apidummy.dummy.com
aws-lambda-list-versions-by-function
Returns a list of versions, with the version-specific configuration of each.
Base Command
aws-lambda-list-versions-by-function
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
| functionName | The name of the Lambda function, version, or alias. You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length. | Required |
| Marker | Specify the pagination token that’s returned by a previous request to retrieve the next page of results. | Optional |
| MaxItems | The maximum number of versions to return. Note that ListVersionsByFunction returns a maximum of 50 items in each response, even if you set the number higher. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.NextMarker | String | The pagination token that’s included if more results are available. |
| AWS.Lambda.Versions.FunctionName | String | The name of the function. |
| AWS.Lambda.Versions.FunctionArn | String | The function’s Amazon Resource Name (ARN). |
| AWS.Lambda.Versions.Runtime | String | The identifier of the function’s runtime. Runtime is required if the deployment package is a .zip file archive. |
| AWS.Lambda.Versions.Role | String | The function’s execution role. |
| AWS.Lambda.Versions.Handler | String | The function that Lambda calls to begin running your function. |
| AWS.Lambda.Versions.CodeSize | Number | The size of the function’s deployment package, in bytes. |
| AWS.Lambda.Versions.Description | String | The function’s description. |
| AWS.Lambda.Versions.Timeout | Number | The amount of time in seconds that Lambda allows a function to run before stopping it. |
| AWS.Lambda.Versions.MemorySize | Number | The amount of memory available to the function at runtime. |
| AWS.Lambda.Versions.LastModified | String | The date and time that the function was last updated, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD). |
| AWS.Lambda.Versions.CodeSha256 | String | The SHA256 hash of the function’s deployment package. |
| AWS.Lambda.Versions.Version | String | The version of the Lambda function. |
| AWS.Lambda.Versions.VpcConfig.SubnetIds | String | A list of VPC subnet IDs. |
| AWS.Lambda.Versions.VpcConfig.SecurityGroupIds | String | A list of VPC security group IDs. |
| AWS.Lambda.Versions.VpcConfig.VpcId | String | The ID of the VPC. |
| AWS.Lambda.Versions.DeadLetterConfig.TargetArn | String | The Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic. |
| AWS.Lambda.Versions.Environment.Variables.string | String | Environment variable key-value pairs. Omitted from CloudTrail logs. |
| AWS.Lambda.Versions.Environment.Error.ErrorCode | String | The error code for environment variables that couldn’t be applied. |
| AWS.Lambda.Versions.Environment.Error.Message | String | The error message for environment variables that couldn’t be applied. |
| AWS.Lambda.Versions.KMSKeyArn | String | The ARN of the KMS key used to encrypt the function’s environment variables. |
| AWS.Lambda.Versions.TracingConfig.Mode | String | The tracing mode for the Lambda function. |
| AWS.Lambda.Versions.MasterArn | String | The ARN of the main function for Lambda@Edge functions. |
| AWS.Lambda.Versions.FunctionVersion | String | The specific function version. |
| AWS.Lambda.Versions.Tags | Object | The tags assigned to the Lambda function. |
| AWS.Lambda.Versions.State | String | The current state of the function. When the state is Inactive, you can reactivate the function by invoking it. |
| AWS.Lambda.Versions.StateReason | String | The reason for the function’s current state. |
| AWS.Lambda.Versions.StateReasonCode | String | The reason code for the current state of the function. |
| AWS.Lambda.Versions.LastUpdateStatus | String | The status of the last update that was performed on the function. This is first set to Successful after function creation completes. |
| AWS.Lambda.Versions.LastUpdateStatusReason | String | The reason for the last update that was performed on the function. |
| AWS.Lambda.Versions.LastUpdateStatusReasonCode | String | The reason code for the last update operation status. |
| AWS.Lambda.Versions.PackageType | String | The type of deployment package. Set to Image for container image and set Zip for .zip file archive. |
| AWS.Lambda.Versions.ImageConfigResponse.ImageConfigError.ErrorCode | String | The error code for image configuration. |
| AWS.Lambda.Versions.ImageConfigResponse.ImageConfigError.Message | String | The error message for image configuration. |
| AWS.Lambda.Versions.ImageConfigResponse.ImageConfigError.Type | String | The error type for image configuration. |
| AWS.Lambda.Versions.ImageConfigResponse.ImageConfig | Object | The image configuration values. |
Command example
!aws-lambda-list-versions-by-function functionName=test
Context Example
{
"AWS": {
"Lambda": {
"Versions": [
{
"Architectures": [
"test"
],
"CodeSha256": "111111111111111",
"CodeSize": 111,
"Description": "",
"EphemeralStorage": {
"Size": 111
},
"FunctionArn": "arn:aws:dummy-api:dummy:12345678:dummy/*/*/test",
"FunctionName": "test",
"Handler": "handler",
"LastModified": "2024-06-05T11:54:29.646+0000",
"MemorySize": 128,
"PackageType": "Zip",
"RevisionId": "11111-11111-1111",
"Role": "dummyy.111111:role/dummy-role/test-role-11111",
"Runtime": "nodejs18.x",
"SnapStart": {
"ApplyOn": "None",
"OptimizationStatus": "Off"
},
"Timeout": 3,
"TracingConfig": {
"Mode": "PassThrough"
},
"Version": "$LATEST"
}
]
}
}
}
Human Readable Output
Versions
Function Name Role Runtime Last Modified State Description test dummy.111111:role/dummy-role/test-role-11111 nodejs18.x 2024-06-05T11:54:29.646+0000
aws-lambda-get-function-url-config
Returns details about a Lambda function URL.
Base Command
aws-lambda-get-function-url-config
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
| functionName | The name of the Lambda function, version, or alias. You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length. | Required |
| qualifier | The alias name. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.FunctionURLConfig.FunctionUrl | String | The HTTP URL endpoint for the function. |
| AWS.Lambda.FunctionURLConfig.FunctionArn | String | The Amazon Resource Name (ARN) of your function. |
| AWS.Lambda.FunctionURLConfig.AuthType | String | The type of authentication that the function URL uses. Set to AWS_IAM if you want to restrict access to authenticated users only. Set to NONE if you want to bypass IAM authentication to create a public endpoint. |
| AWS.Lambda.FunctionURLConfig.Cors.AllowCredentials | Boolean | Whether to allow cookies or other credentials in requests to the function URL. The default is false. |
| AWS.Lambda.FunctionURLConfig.Cors.AllowHeaders | List | The HTTP headers that origins can include in requests to the function URL. For example Date, Keep-Alive, X-Custom-Header. |
| AWS.Lambda.FunctionURLConfig.Cors.AllowMethods | List | The HTTP methods that are allowed when calling the function URL. For example GET, POST, DELETE, or the wildcard character ( *). |
| AWS.Lambda.FunctionURLConfig.Cors.AllowOrigins | List | The origins that can access the function URL.You can list any number of specific origins, separated by a comma. For example https://www.example.com, http://localhost:8080. Alternatively, you can grant access to all origins using the wildcard character ( *). |
| AWS.Lambda.FunctionURLConfig.Cors.ExposeHeaders | List | The HTTP headers in the function response that you want to expose to origins that call the function URL. For example Date, Keep-Alive, X-Custom-Header. |
| AWS.Lambda.FunctionURLConfig.Cors.MaxAge | Number | The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By default, this is set to 0, which means that the browser doesn’t cache results. |
| AWS.Lambda.FunctionURLConfig.CreationTime | String | When the function URL was created, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD). |
| AWS.Lambda.FunctionURLConfig.LastModifiedTime | String | When the function URL configuration was last updated, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD). |
| AWS.Lambda.FunctionURLConfig.InvokeMode | String | Use one of the following options: BUFFERED – This is the default option. Lambda invokes your function using the Invoke API operation. Invocation results are available when the payload is complete. The maximum payload size is 6 MB. RESPONSE_STREAM – Your function streams payload results as they become available. Lambda invokes your function using the InvokeWithResponseStream API operation. The maximum response payload size is 20 MB, however, you can request a quota increase. |
Command example
!aws-lambda-get-function-url-config functionName="test"
Context Example
{
"AWS": {
"Lambda": {
"FunctionURLConfig": {
"AuthType": "NONE",
"CreationTime": "2024-05-02T07:23:12.573458Z",
"FunctionArn": "dummy111111:role/dummy/test-11111",
"FunctionUrl": "hxxps://dummy.com/",
"InvokeMode": "BUFFERED",
"LastModifiedTime": "2024-05-02T07:23:12.573458Z"
}
}
}
}
Human Readable Output
Function URL Config
Auth Type Creation Time Function Arn Function Url Invoke Mode Last Modified Time NONE 2024-05-02T07:23:12.573458Z dummy.111111:role/dummy/test-11111 hxxps://dummy.com/ BUFFERED 2024-05-02T07:23:12.573458Z
aws-lambda-get-function-configuration
Returns the version-specific settings of a Lambda function or version. The output includes only options that can vary between versions of a function.
Base Command
aws-lambda-get-function-configuration
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
| functionName | The name of the Lambda function, version, or alias. You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length. | Required |
| qualifier | Specify a version or alias to get details about a published version of the function. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.FunctionConfig.FunctionName | String | The name of the function. |
| AWS.Lambda.FunctionConfig.FunctionArn | String | The function’s Amazon Resource Name (ARN). |
| AWS.Lambda.FunctionConfig.Runtime | String | The identifier of the function’s runtime. Runtime is required if the deployment package is a .zip file archive. |
| AWS.Lambda.FunctionConfig.Role | String | The function’s execution role. |
| AWS.Lambda.FunctionConfig.Handler | String | The function that Lambda calls to begin running your function. |
| AWS.Lambda.FunctionConfig.CodeSize | Number | The size of the function’s deployment package, in bytes. |
| AWS.Lambda.FunctionConfig.Description | String | The function’s description. |
| AWS.Lambda.FunctionConfig.Timeout | Number | The amount of time in seconds that Lambda allows a function to run before stopping it. |
| AWS.Lambda.FunctionConfig.MemorySize | Number | The amount of memory available to the function at runtime. |
| AWS.Lambda.FunctionConfig.LastModified | String | The date and time that the function was last updated, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD). |
| AWS.Lambda.FunctionConfig.CodeSha256 | String | The SHA256 hash of the function’s deployment package. |
| AWS.Lambda.FunctionConfig.Version | String | The version of the Lambda function. |
| AWS.Lambda.FunctionConfig.VpcConfig.SubnetIds | String | A list of VPC subnet IDs. |
| AWS.Lambda.FunctionConfig.VpcConfig.SecurityGroupIds | String | A list of VPC security group IDs. |
| AWS.Lambda.FunctionConfig.VpcConfig.VpcId | String | The ID of the VPC. |
| AWS.Lambda.FunctionConfig.DeadLetterConfig.TargetArn | String | The Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic. |
| AWS.Lambda.FunctionConfig.Environment.Variables.string | String | Environment variable key-value pairs. Omitted from CloudTrail logs. |
| AWS.Lambda.FunctionConfig.Environment.Error.ErrorCode | String | The error code for environment variables that couldn’t be applied. |
| AWS.Lambda.FunctionConfig.Environment.Error.Message | String | The error message for environment variables that couldn’t be applied. |
| AWS.Lambda.FunctionConfig.KMSKeyArn | String | The ARN of the KMS key used to encrypt the function’s environment variables. |
| AWS.Lambda.FunctionConfig.TracingConfig.Mode | String | The tracing mode for the Lambda function. |
| AWS.Lambda.FunctionConfig.MasterArn | String | The ARN of the main function for Lambda@Edge functions. |
| AWS.Lambda.FunctionConfig.FunctionVersion | String | The specific function version. |
| AWS.Lambda.FunctionConfig.Tags | Object | The tags assigned to the Lambda function. |
| AWS.Lambda.FunctionConfig.State | String | The current state of the function. When the state is Inactive, you can reactivate the function by invoking it. |
| AWS.Lambda.FunctionConfig.StateReason | String | The reason for the function’s current state. |
| AWS.Lambda.FunctionConfig.StateReasonCode | String | The reason code for the current state of the function. |
| AWS.Lambda.FunctionConfig.LastUpdateStatus | String | The status of the last update that was performed on the function. This is first set to Successful after function creation completes. |
| AWS.Lambda.FunctionConfig.LastUpdateStatusReason | String | The reason for the last update that was performed on the function. |
| AWS.Lambda.FunctionConfig.LastUpdateStatusReasonCode | String | The reason code for the last update operation status. |
| AWS.Lambda.FunctionConfig.PackageType | String | The type of deployment package. Set to Image for container image and set Zip for .zip file archive. |
| AWS.Lambda.FunctionConfig.ImageConfigResponse.ImageConfigError.ErrorCode | String | The error code for image configuration. |
| AWS.Lambda.FunctionConfig.ImageConfigResponse.ImageConfigError.Message | String | The error message for image configuration. |
| AWS.Lambda.FunctionConfig.ImageConfigResponse.ImageConfigError.Type | String | The error type for image configuration. |
| AWS.Lambda.FunctionConfig.ImageConfigResponse.ImageConfig | Object | The image configuration values. |
Command example
!aws-lambda-get-function-configuration functionName=test
Context Example
{
"AWS": {
"Lambda": {
"FunctionConfig": {
"Architectures": [
"x86"
],
"CodeSha256": "111111/1111111",
"CodeSize": 000,
"Description": "",
"EphemeralStorage": {
"Size": 000
},
"FunctionArn": "arn:aws:lambda:dummy1111:function:test",
"FunctionName": "test",
"Handler": "handler",
"LastModified": "2024-06-05T11:54:29.646+0000",
"LastUpdateStatus": "Successful",
"MemorySize": 128,
"PackageType": "Zip",
"RevisionId": "11111-1111-11111",
"Role": "11111:role/dummy-role/test-role-11111",
"Runtime": "nodejs18.x",
"RuntimeVersionConfig": {
"RuntimeVersionArn": "arn:aws:lambda:dummy::runtime11111111"
},
"SnapStart": {
"ApplyOn": "None",
"OptimizationStatus": "Off"
},
"State": "Active",
"Timeout": 3,
"TracingConfig": {
"Mode": "PassThrough"
},
"Version": "$LATEST"
}
}
}
}
Human Readable Output
Function Configuration
Code Sha256 Description Function Arn Function Name Revision Id Runtime State 11111111 dummy:role/dummy-role/test-role-11111 test 11111-11111-111 nodejs18.x Active
aws-lambda-delete-function-url-config
Deletes a Lambda function URL. When you delete a function URL, you can’t recover it. Creating a new function URL results in a different URL address.
Base Command
aws-lambda-delete-function-url-config
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
| functionName | The name of the Lambda function, version, or alias. You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length. | Required |
| qualifier | Specify a version or alias to get details about a published version of the function. | Optional |
Context Output
There is no context output for this command.
aws-lambda-delete-function
Deletes a Lambda function. To delete a specific function version, use the Qualifier parameter. Otherwise, all versions and aliases are deleted.
Base Command
aws-lambda-delete-function
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
| functionName | The name of the Lambda function, version, or alias. You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length. | Required |
| qualifier | Specify a version or alias to get details about a published version of the function. | Optional |
Context Output
There is no context output for this command.
aws-lambda-create-function
Creates a Lambda function. To create a function, you need a deployment package and an execution role.
Base Command
aws-lambda-create-function
Input
| Argument Name | Description | Required |
|---|---|---|
| functionName | The name of the Lambda function. | Required |
| runtime | The runtime environment for the function. | Required |
| handler | The name of the method within your code that Lambda calls to execute your function. Example: lambda_function.lambda_handler’. | Required |
| code | Entry ID of the uploaded base64-encoded contents of the deployment package. Amazon Web Services SDK and CLI clients handle the encoding for you. | Optional |
| S3-bucket | An Amazon S3 bucket in the same Amazon Web Services Region as your function. The bucket can be in a different Amazon Web Services account. | Optional |
| description | A description of the function. | Optional |
| functionTimeout | The amount of time that Lambda allows a function to run before stopping it. Default is 3. | Optional |
| memorySize | The amount of memory available to the function at runtime. Default is 128. | Optional |
| publish | Set to true to publish the first version of the function during creation. Possible values are: True, False. | Optional |
| vpcConfig | Json string contains SubnetIds - list of VPC subnet IDs, SecurityGroupIds - A list of VPC security group IDs, and boolean Ipv6AllowedForDualStack - allows outbound IPv6 traffic. | Optional |
| packageType | The type of deployment package. Possible values are: Image, Zip. | Optional |
| environment | The environment variables for the function. Should be given as key-value pairs in a json string. | Optional |
| tracingConfig | The tracing configuration for the function. Set to Active to sample and trace a subset of incoming requests with X-Ray. Default is Active. | Optional |
| tags | The list of tags to apply to the function. | Optional |
| role | The Amazon Resource Name (ARN) of the function’s execution role. | Required |
| layers | A list of function layers to add to the function’s execution environment. | Optional |
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.Functions.FunctionName | string | The name of the function. |
| AWS.Lambda.Functions.FunctionArn | string | The function’s Amazon Resource Name (ARN). |
| AWS.Lambda.Functions.Runtime | string | The identifier of the function’s runtime. Runtime is required if the deployment package is a .zip file archive. |
| AWS.Lambda.Functions.Role | string | The function’s execution role. |
| AWS.Lambda.Functions.Handler | string | The function that Lambda calls to begin running your function. |
| AWS.Lambda.Functions.CodeSize | number | The size of the function’s deployment package, in bytes. |
| AWS.Lambda.Functions.Description | string | The function’s description. |
| AWS.Lambda.Functions.Timeout | number | The amount of time in seconds that Lambda allows a function to run before stopping it. |
| AWS.Lambda.Functions.MemorySize | number | The amount of memory available to the function at runtime. |
| AWS.Lambda.Functions.Version | string | The version of the Lambda function. |
| AWS.Lambda.Functions.VpcConfig.SubnetIds | list | A list of VPC subnet IDs. |
| AWS.Lambda.Functions.VpcConfig.SecurityGroupIds | list | A list of VPC security group IDs. |
| AWS.Lambda.Functions.VpcConfig.VpcId | string | The ID of the VPC. |
| AWS.Lambda.Functions.VpcConfig.Ipv6AllowedForDualStack | boolean | Allows outbound IPv6 traffic on VPC functions that are connected to dual-stack subnets. |
| AWS.Lambda.Functions.PackageType | string | The type of deployment package. Set to Image for container image and set Zip for .zip file archive. |
| AWS.Lambda.Functions.LastModified | string | The date and time that the function was last updated, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD). |
Command example
!aws-lambda-create-function code=entry_id functionName=test runtime=nodejs role=test-role handler=test.handler vpcConfig="{\"SubnetIds\": [\"subnet-1\",\"subnet-2\"], \"SecurityGroupIds\":[\"sg-1\"]}"
Context Example
{
"AWS": {
"Lambda": {
"Functions": {
"FunctionName": "test",
"FunctionArn": "test",
"Runtime": "nodejs",
"Role": "test-role",
"Handler": "test.handler",
"CodeSize": 30,
"Description": "test function",
"Timeout": 30,
"MemorySize": 123,
"Version": "test",
"VpcConfig": {
"SubnetIds": ["subnet-1","subnet-2"],
"SecurityGroupIds": ["sg-1"],
"VpcId": "test",
"Ipv6AllowedForDualStack": true},
"PackageType": "Zip",
"LastModified": "test"}
}
}
}
Human Readable Output
Create Function
Function Name Function Arn Runtime Role Handler Code Size Description Timeout Memory Size Version Vpc Config Package Type Last Modified test test nodejs test-role test.handler 30 test function 30 123 test SubnetIds: subnet-1,
subnet-2
SecurityGroupIds: sg-1
VpcId: test
Ipv6AllowedForDualStack: trueZip test
aws-lambda-publish-layer-version
Creates an Lambda layer from a ZIP archive.
Base Command
aws-lambda-publish-layer-version
Input
| Argument Name | Description | Required |
|---|---|---|
| layer-name | The name or Amazon Resource Name (ARN) of the layer. | Required |
| description | The description of the version. | Optional |
| s3-bucket | The Amazon S3 bucket of the layer archive. | Optional |
| s3-key | The Amazon S3 key of the layer archive. | Optional |
| s3-object-version | For versioned objects, the version of the layer archive object to use. | Optional |
| zip-file | Entry ID of the base64-encoded contents of the layer archive. | Optional |
| compatible-runtimes | The name of the method within your code that Lambda calls to execute your function. | Optional |
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
| compatible-architectures | A list of compatible architectures. Possible values are: x86_64, arm64. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.Layers.LayerVersionArn | string | The ARN of the layer version. |
| AWS.Lambda.Layers.LayerArn | string | The ARN of the layer. |
| AWS.Lambda.Layers.Description | string | The description of the version. |
| AWS.Lambda.Layers.CreatedDate | string | The date that the layer version was created, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD). |
| AWS.Lambda.Layers.Version | number | The version number. |
| AWS.Lambda.Layers.CompatibleRuntimes | list | The layer’s compatible runtimes. |
| AWS.Lambda.Layers.CompatibleArchitectures | list | The layer’s compatible architectures. |
Command example
```!aws-lambda-publish-layer-version layer-name=test zip-file=entry_id description=test-layer-3
#### Context Example
```json
{
"CompatibleRuntimes": ["nodejs"],
"CreatedDate": "2024-03-01T10:12:00.0TZD",
"Description": "test",
"LayerArn": "test_layer_arn",
"LayerVersionArn": "test_version_arn",
"Version": 2
}
Human Readable Output
Publish Layer Version
Layer Version Arn Layer Arn Description Created Date Version Compatible Runtimes test_version_arn test_layer_arn test 2024-03-01T10:12:00.0TZD 2 nodejs
aws-lambda-list-layer-version
Lists the versions of an Lambda layer.
Base Command
aws-lambda-list-layer-version
Input
| Argument Name | Description | Required |
|---|---|---|
| compatible-runtime | A runtime identifier. For example, java21. | Optional |
| layer-name | The name or Amazon Resource Name (ARN) of the layer. | Required |
| token | A pagination token returned by a previous call. | Optional |
| limit | The maximum number of versions to return. | Optional |
| compatible-architecture | The compatible instruction set architecture. | Optional |
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Lambda.LayerVersionsNextToken | string | A pagination token returned when the response doesn’t contain all versions. |
| AWS.Lambda.Layers.LayerVersionArn | string | The ARN of the layer version. |
| AWS.Lambda.Layers.Version | number | The version number. |
| AWS.Lambda.Layers.Description | string | The description of the version. |
| AWS.Lambda.Layers.CreatedDate | string | The date that the version was created, in ISO 8601 format. For example, 2018-11-27T15:10:45.123+0000. |
| AWS.Lambda.Layers.CompatibleRuntimes | list | The layer’s compatible runtimes. |
| AWS.Lambda.Layers.LicenseInfo | string | The layer’s open-source license. |
| AWS.Lambda.Layers.CompatibleArchitectures | list | A list of compatible instruction set architectures. |
Command example
!aws-lambda-list-layer-version layer-name=test
Context Example
{
"NextMarker": "test_marker",
"LayerVersions": [{
"LayerVersionArn": "testLayer",
"Version": 1,
"Description": "test",
"CreatedDate": "2018-11-27T15:10:45.123+0000",
"CompatibleRuntimes": ["nodejs"],
"LicenseInfo": "test",
"CompatibleArchitectures": ["x86_64"]
}]
}
Human Readable Output
Layer Version List
Compatible Architectures Compatible Runtimes Created Date Description Layer Version Arn License Info Version x86_64 nodejs 2018-11-27T15:10:45.123+0000 test testLayer test 1
aws-lambda-delete-layer-version
Deletes a version of an Lambda layer.
Base Command
aws-lambda-delete-layer-version
Input
| Argument Name | Description | Required |
|---|---|---|
| version-number | The version number. | Required |
| layer-name | The name or Amazon Resource Name (ARN) of the layer. | Required |
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
Command example
!aws-lambda-delete-layer-version version-number=4 layer-name=test_layer
Context Output
There is no context output for this command.
Human Readable Output
Deleted version number 2 of testLayer Successfully
Configuration parameters
defaultRegion— AWS Default Region (required)roleArn— Role ArnroleSessionName— Role Session NamesessionDuration— Role Session Durationcredentials— Access Keyaccess_key— Access Keysecret_key— Secret Keytimeout— Timeoutretries— Retriesendpoint_url— PrivateLink service URL.sts_endpoint_url— STS PrivateLink URLsts_regional_endpoint— AWS STS Regional Endpointsinsecure— Trust any certificate (not secure)proxy— Use system proxy settings
Commands (15)
-
aws-lambda-create-functionCreates a Lambda function. To create a function, you need a deployment package and an execution role.
-
aws-lambda-delete-functionDeletes a Lambda function. To delete a specific function version, use the Qualifier parameter. Otherwise, all versions and aliases are deleted.
-
aws-lambda-delete-function-url-configDeletes a Lambda function URL. When you delete a function URL, you can’t recover it. Creating a new function URL results in a different URL address.
-
aws-lambda-delete-layer-versionDeletes a version of an Lambda layer.
-
aws-lambda-get-account-settingsRetrieves details about your account's limits and usage in an AWS Region.
-
aws-lambda-get-functionReturns the configuration information of the Lambda function and a presigned URL link to the .zip file you uploaded with CreateFunction so you can download the .zip file. Note that the URL is valid for up to 10 minutes. The configuration information is the same information you provided as parameters when uploading the function. Use the Qualifier parameter to retrieve a published version of the function. Otherwise, returns the unpublished version ($LATEST ).
-
aws-lambda-get-function-configurationReturns the version-specific settings of a Lambda function or version. The output includes only options that can vary between versions of a function.
-
aws-lambda-get-function-url-configReturns details about a Lambda function URL.
-
aws-lambda-get-policyReturns the resource-based IAM policy for a function, version, or alias.
-
aws-lambda-invokeInvokes a Lambda function. Specify just a function name to invoke the latest version of the function. To invoke a published version, use the Qualifier parameter to specify a version or alias. If you use the RequestResponse (synchronous) invocation option, note that the function may be invoked multiple times if a timeout is reached. For functions with a long timeout, your client may be disconnected during synchronous invocation while it waits for a response. Use the "timeout" and "retries" arguments to control this behavior. If you use the Event (asynchronous) invocation option, the function will be invoked at least once in response to an event and the function must be idempotent to handle this.
-
aws-lambda-list-aliasesReturns a list of aliases created for a Lambda function. For each alias, the response includes information such as the alias ARN, description, alias name, and the function version to which it points.
-
aws-lambda-list-functionsReturns a list of your Lambda functions. For each function, the response includes the function configuration information. You must use GetFunction to retrieve the code for your function.
-
aws-lambda-list-layer-versionLists the versions of an Lambda layer.
-
aws-lambda-list-versions-by-functionReturns a list of versions, with the version-specific configuration of each.
-
aws-lambda-publish-layer-versionCreates an Lambda layer from a ZIP archive.
import demistomock as demisto # noqa: F401 from AWSApiModule import * from CommonServerPython import * # noqa: F401 """IMPORTS""" from datetime import date import urllib3.util # Disable insecure warnings urllib3.disable_warnings() def config_aws_session(args: dict[str, str], aws_client: AWSClient): """ Configures an AWS session for the Lambda service, Used in all the commands. Args: args (dict): A dictionary containing the configuration parameters for the session. - 'region' (str): The AWS region. - 'roleArn' (str): The ARN of the IAM role. - 'roleSessionName' (str): The name of the role session. - 'roleSessionDuration' (str): The duration of the role session. aws_client (AWSClient): The AWS client used to configure the session. Returns: AWS session (boto3 client): The configured AWS session. """ return aws_client.aws_session( service="lambda", region=args.get("region"), role_arn=args.get("roleArn"), role_session_name=args.get("roleSessionName"), role_session_duration=args.get("roleSessionDuration"), ) def _parse_policy_response(data: dict[str, Any]) -> tuple[dict, list | None]: """ Parses the response data representing a policy into a structured format. Args: data (dict): The response data containing the policy information. Returns: tuple[dict[str, Any], list[dict[str, str | None]]]: A tuple containing the parsed policy information. The first element of the tuple is a dictionary representing the policy metadata with the following keys: - "Id" (str): The ID of the policy. - "Version" (str): The version of the policy. - "RevisionId" (str): The revision ID of the policy. The second element of the tuple is a list of dictionaries representing the policy statements. Each dictionary in the list represents a statement with the following keys: - "Sid" (str): The ID of the statement. - "Effect" (str): The effect of the statement (e.g., "Allow" or "Deny"). - "Action" (str): The action associated with the statement. - "Resource" (str): The resource associated with the statement. - "Principal" (str | None): The principal associated with the statement, if applicable. """ policy: dict[str, Any] = data.get("Policy", {}) statements: list[dict[str, str | None]] = policy.get("Statement", []) if len(statements) == 1: return { "Sid": statements[0].get("Sid"), "Effect": statements[0].get("Effect"), "Action": statements[0].get("Action"), "Resource": statements[0].get("Resource"), "Principal": statements[0].get("Principal"), }, None else: policy_table = { "Id": policy.get("Id"), "Version": policy.get("Version"), "RevisionId": data.get("RevisionId"), } statements_table = [ { "Sid": statement.get("Sid"), "Effect": statement.get("Effect"), "Action": statement.get("Action"), "Resource": statement.get("Resource"), "Principal": statement.get("Principal"), } for statement in statements ] return policy_table, statements_table def parse_tag_field(tags_str): tags = [] regex = re.compile(r"key=([\w\d_:.-]+),value=([ /\w\d@_,.\*-]+)", flags=re.I) for f in tags_str.split(";"): match = regex.match(f) if match is None: demisto.debug(f"could not parse field: {f}") continue tags.append({"Key": match.group(1), "Value": match.group(2)}) return tags class DatetimeEncoder(json.JSONEncoder): # pylint: disable=method-hidden def default(self, obj): if isinstance(obj, datetime): return obj.strftime("%Y-%m-%dT%H:%M:%S") elif isinstance(obj, date): return obj.strftime("%Y-%m-%d") # Let the base class default method raise the TypeError return json.JSONEncoder.default(self, obj) def parse_resource_ids(resource_id: str): id_list = resource_id.replace(" ", "") return id_list.split(",") def create_entry(title: str, data: dict, ec: dict): return { "ContentsFormat": formats["json"], "Type": entryTypes["note"], "Contents": data, "ReadableContentsFormat": formats["markdown"], "HumanReadable": tableToMarkdown(title, data) if data else "No result were found", "EntryContext": ec, } def read_zip_to_bytes(filename): """ Reads the entire zip file into a bytes object in chunks. Args: filename: Path to the zip file. Returns: A bytes object containing the complete zip file content. """ with open(filename, "rb") as zip_file: data = b"" for chunk in iter(lambda: zip_file.read(1024), b""): data += chunk return data def prepare_create_function_kwargs(args: dict[str, str]): """ Prepare arguments to be sent to the API """ create_function_api_keys = ["FunctionName", "Runtime", "Role", "Handler", "Description", "PackageType"] kwargs = {} if code_path := args.get("code"): file_path = demisto.getFilePath(code_path).get("path") method_code = read_zip_to_bytes(file_path) kwargs.update({"Code": {"ZipFile": method_code}}) elif s3_bucket := args.get("S3-bucket"): kwargs.update({"Code": {"S3Bucket": s3_bucket}}) else: raise DemistoException("code or S3-bucket must be provided.") kwargs["TracingConfig"] = {"Mode": args.get("tracingConfig") or "Active"} kwargs["MemorySize"] = arg_to_number(args.get("memorySize")) or 128 # type: ignore kwargs["Timeout"] = arg_to_number(args.get("functionTimeout")) or 3 # type: ignore for key in create_function_api_keys: arg_name = key[0].lower() + key[1:] if arg_name in args: kwargs.update({key: args.get(arg_name)}) # type: ignore if publish := args.get("publish"): kwargs["Publish"] = argToBoolean(publish) if env := args.get("environment"): kwargs["Environment"] = {"Variables": {json.loads(env)}} if tags := args.get("tags"): kwargs["Tags"] = argToBoolean(tags) if layers := args.get("layers"): kwargs["Layers"] = argToList(layers) if vpc := args.get("vpcConfig"): kwargs["VpcConfig"] = json.loads(vpc) return kwargs """MAIN FUNCTIONS""" def get_function(args: dict, aws_client): obj = vars(aws_client._client_config) kwargs = {"FunctionName": args.get("functionName")} if args.get("qualifier") is not None: kwargs.update({"Qualifier": args.get("qualifier")}) response = aws_client.get_function(**kwargs) func = response["Configuration"] data = { "FunctionName": func["FunctionName"], "FunctionArn": func["FunctionArn"], "Runtime": func["Runtime"], "Region": obj["_user_provided_options"]["region_name"], } raw = json.loads(json.dumps(response, cls=DatetimeEncoder)) if raw: raw.update({"Region": obj["_user_provided_options"]["region_name"]}) ec = {"AWS.Lambda.Functions(val.FunctionArn === obj.FunctionArn)": raw} human_readable = tableToMarkdown("AWS Lambda Functions", data) return_outputs(human_readable, ec) def list_functions(aws_client): obj = vars(aws_client._client_config) data = [] output = [] paginator = aws_client.get_paginator("list_functions") for response in paginator.paginate(): for function in response["Functions"]: data.append( { "FunctionName": function["FunctionName"], "FunctionArn": function["FunctionArn"], "Runtime": function["Runtime"], "LastModified": function["LastModified"], "Region": obj["_user_provided_options"]["region_name"], } ) output.append(function) raw = json.loads(json.dumps(response, cls=DatetimeEncoder)) if raw: raw.update({"Region": obj["_user_provided_options"]["region_name"]}) ec = {"AWS.Lambda.Functions(val.FunctionArn === obj.FunctionArn)": raw} human_readable = tableToMarkdown("AWS Lambda Functions", data) return_outputs(human_readable, ec) def list_aliases(args, aws_client): data = [] output = [] kwargs = {"FunctionName": args.get("functionName")} if args.get("functionVersion") is not None: kwargs.update({"FunctionVersion": args.get("functionVersion")}) paginator = aws_client.get_paginator("list_aliases") for response in paginator.paginate(**kwargs): for alias in response["Aliases"]: data.append( { "AliasArn": alias["AliasArn"], "Name": alias["Name"], "FunctionVersion": alias["FunctionVersion"], } ) output.append(alias) try: raw = json.loads(json.dumps(output, cls=DatetimeEncoder)) except ValueError as e: return_error(f"Could not decode/encode the raw response - {e}") ec = {"AWS.Lambda.Aliases(val.AliasArn === obj.AliasArn)": raw} human_readable = tableToMarkdown("AWS Lambda Aliases", data) return_outputs(human_readable, ec) def invoke(args, aws_client): obj = vars(aws_client._client_config) kwargs = {"FunctionName": args.get("functionName")} if args.get("invocationType") is not None: kwargs.update({"InvocationType": args.get("invocationType")}) if args.get("logType") is not None: kwargs.update({"LogType": args.get("logType")}) if args.get("clientContext") is not None: kwargs.update({"ClientContext": args.get("clientContext")}) if args.get("payload") is not None: payload = args.get("payload") if (not isinstance(payload, str)) or (not payload.startswith("{") and not payload.startswith("[")): payload = json.dumps(payload) kwargs.update({"Payload": payload}) if args.get("qualifier") is not None: kwargs.update({"Qualifier": args.get("qualifier")}) response = aws_client.invoke(**kwargs) data = { "FunctionName": args.get("functionName"), "Region": obj["_user_provided_options"]["region_name"], "RequestPayload": args.get("payload"), } if "LogResult" in response: data.update({"LogResult": base64.b64decode(response["LogResult"]).decode("utf-8")}) # type:ignore if "Payload" in response: data.update({"Payload": response["Payload"].read().decode("utf-8")}) # type:ignore if "ExecutedVersion" in response: data.update({"ExecutedVersion": response["ExecutedVersion"]}) # type:ignore if "FunctionError" in response: data.update({"FunctionError": response["FunctionError"]}) human_readable = tableToMarkdown("AWS Lambda Invoked Functions", data) return CommandResults( outputs=data, readable_output=human_readable, outputs_prefix="AWS.Lambda.InvokedFunctions", outputs_key_field=["FunctionName", "RequestPayload"], ) def remove_permission(args, aws_client): kwargs = {"FunctionName": args.get("functionName"), "StatementId": args.get("StatementId")} if args.get("Qualifier") is not None: kwargs.update({"Qualifier": args.get("Qualifier")}) if args.get("RevisionId") is not None: kwargs.update({"RevisionId": args.get("RevisionId")}) response = aws_client.remove_permission(**kwargs) if response["ResponseMetadata"]["HTTPStatusCode"] == 200: demisto.results("Permissions have been removed") def get_account_settings(args, aws_client): obj = vars(aws_client._client_config) response = aws_client.get_account_settings() account_limit = response["AccountLimit"] account_usage = response["AccountUsage"] data = { "AccountLimit": { "TotalCodeSize": str(account_limit["TotalCodeSize"]), "CodeSizeUnzipped": str(account_limit["CodeSizeUnzipped"]), "CodeSizeZipped": str(account_limit["CodeSizeZipped"]), "ConcurrentExecutions": str(account_limit["ConcurrentExecutions"]), "UnreservedConcurrentExecutions": str(account_limit["UnreservedConcurrentExecutions"]), }, "AccountUsage": { "TotalCodeSize": str(account_usage["TotalCodeSize"]), "FunctionCount": str(account_usage["FunctionCount"]), }, } try: raw = json.loads(json.dumps(response, cls=DatetimeEncoder)) except ValueError as e: return_error(f"Could not decode/encode the raw response - {e}") if raw: raw.update({"Region": obj["_user_provided_options"]["region_name"]}) ec = {"AWS.Lambda.Functions(val.Region === obj.Region)": raw} human_readable = tableToMarkdown("AWS Lambda Functions", data) return_outputs(human_readable, ec) def get_policy_command(args: dict[str, str], aws_client) -> CommandResults: """ Retrieves the policy for a Lambda function from AWS and parses it into a dictionary. Args: args (dict): A dictionary containing the function name and optional qualifier. aws_client: The AWS client(boto3 client) used to retrieve the policy. Returns: CommandResults: An object containing the parsed policy as outputs, a readable output in Markdown format, and relevant metadata. """ kwargs = {"FunctionName": args["functionName"]} if qualifier := args.get("qualifier"): kwargs["qualifier"] = qualifier response = aws_client.get_policy(**kwargs) response["Policy"] = json.loads(response["Policy"]) response.pop("ResponseMetadata", None) parsed_policy, parsed_statement = _parse_policy_response(response) policy_table = tableToMarkdown(name="Policy", t=parsed_policy) if parsed_statement: # if policy contains a multiple statements, then print the statements in another table statements_table = tableToMarkdown("Statements", t=parsed_statement) policy_table = policy_table + statements_table return CommandResults(outputs=response, readable_output=policy_table, outputs_prefix="AWS.Lambda", outputs_key_field="Sid") def list_versions_by_function_command(args: dict[str, str], aws_client) -> CommandResults: """ Lists the versions of a Lambda function and returns the results as a list of CommandResults objects. Args: args (dict): A dictionary containing the command arguments. - 'functionName' (str): The name of the Lambda function. - 'Marker' (str, optional): The marker for pagination. - 'MaxItems' (str, optional): The maximum number of items to return. aws_client: The AWS client used to list the versions. Returns: list[CommandResults]: A list of CommandResults objects, containing the parsed versions as outputs, a readable output in Markdown format, and relevant metadata. """ def parse_version(version: dict[str, Any]) -> dict[str, str | None]: return { "Function Name": version.get("FunctionName"), "Runtime": version.get("Runtime"), "Role": version.get("Role"), "Description": version.get("Description"), "Last Modified": version.get("LastModified"), "State": version.get("State"), } headers = ["Function Name", "Role", "Runtime", "Last Modified", "State", "Description"] kwargs = {"FunctionName": args["functionName"]} for key in ("Marker", "MaxItems"): if (value := args.get(key)) is not None: kwargs[key] = value response: dict = aws_client.list_versions_by_function(**kwargs) response.pop("ResponseMetadata", None) parsed_versions = [parse_version(version) for version in response.get("Versions", [])] table_for_markdown = tableToMarkdown(name="Versions", t=parsed_versions, headers=headers) if next_marker := response.get("NextMarker"): table_for_markdown += f"\nTo get the next version run the command with the Marker argument with the value: {next_marker}" return CommandResults( outputs=response, readable_output=table_for_markdown, outputs_prefix="AWS.Lambda", outputs_key_field="FunctionName" ) def get_function_url_config_command(args: dict[str, str], aws_client) -> CommandResults: """ Retrieves the URL configuration of a Lambda function from AWS and returns the results as a CommandResults object. Args: args (dict): A dictionary containing the command arguments. - 'functionName' (str): The name of the Lambda function. - 'qualifier' (str, optional): The qualifier of the function. aws_client (boto3 client): The AWS client used to retrieve the URL configuration. Returns: CommandResults: An object containing the URL configuration as outputs, a readable output in Markdown format, and relevant metadata. """ def parse_url_config(data: dict[str, Any]) -> dict[str, str | None]: return { "Function Url": data.get("FunctionUrl"), "Function Arn": data.get("FunctionArn"), "Auth Type": data.get("AuthType"), "Creation Time": data.get("CreationTime"), "Last Modified Time": data.get("LastModifiedTime"), "Invoke Mode": data.get("InvokeMode"), } kwargs = {"FunctionName": args["functionName"]} if qualifier := args.get("qualifier"): kwargs["qualifier"] = qualifier response = aws_client.get_function_url_config(**kwargs) response.pop("ResponseMetadata", None) parsed_url_config = parse_url_config(response) return CommandResults( outputs=response, readable_output=tableToMarkdown(name="Function URL Config", t=parsed_url_config), outputs_prefix="AWS.Lambda.FunctionURLConfig", outputs_key_field="FunctionArn", ) def get_function_configuration_command(args: dict[str, str], aws_client) -> CommandResults: """ Retrieves the configuration of a Lambda function from AWS and returns the results as a CommandResults object. Args: args (dict): A dictionary containing the command arguments. - 'functionName' (str): The name of the Lambda function. - 'qualifier' (str, optional): The qualifier of the function. aws_client (boto3 client): The AWS client used to retrieve the function configuration. Returns: CommandResults: An object containing the function configuration as outputs, a readable output in Markdown format, and relevant metadata. """ def parse_function_configuration(data: dict[str, Any]) -> dict[str, str | None]: return { "Function Name": data.get("FunctionName"), "Function Arn": data.get("FunctionArn"), "Description": data.get("Description"), "State": data.get("State"), "Runtime": data.get("Runtime"), "Code Sha256": data.get("CodeSha256"), "Revision Id": data.get("RevisionId"), } kwargs = {"FunctionName": args["functionName"]} if qualifier := args.get("qualifier"): kwargs["qualifier"] = qualifier response = aws_client.get_function_configuration(**kwargs) response.pop("ResponseMetadata", None) parsed_function_configuration = parse_function_configuration(response) return CommandResults( outputs=response, readable_output=tableToMarkdown(name="Function Configuration", t=parsed_function_configuration), outputs_prefix="AWS.Lambda.FunctionConfig", outputs_key_field="FunctionName", ) def delete_function_url_config_command(args: dict[str, str], aws_client) -> CommandResults: """ Deletes the URL configuration for a Lambda function in AWS. Args: args (dict): A dictionary containing the command arguments. - 'functionName' (str): The name of the Lambda function. - 'qualifier' (str, optional): The qualifier of the function. aws_client (boto3 client): The AWS client used to delete the function URL configuration. Returns: CommandResults: An object containing the result of the deletion operation as a readable output in Markdown format. """ kwargs = {"FunctionName": args["functionName"]} if qualifier := args.get("qualifier"): kwargs["qualifier"] = qualifier aws_client.delete_function_url_config(**kwargs) # raises on error return CommandResults(readable_output=f"Deleted {args['functionName']} Successfully") def delete_function_command(args: dict[str, str], aws_client) -> CommandResults: """ Deletes a Lambda function from AWS. Args: args (dict): A dictionary containing the command arguments. - 'functionName' (str): The name of the Lambda function. - 'qualifier' (str, optional): The qualifier of the function. aws_client (boto3 client): The AWS client used to delete the function. Returns: CommandResults: An object containing the result of the deletion operation as a readable output in Markdown format. """ kwargs = {"FunctionName": args["functionName"]} if qualifier := args.get("qualifier"): kwargs["qualifier"] = qualifier aws_client.delete_function(**kwargs) # raises on error return CommandResults(readable_output=f"Deleted {args['functionName']} Successfully") def create_function_command(args: dict[str, str], aws_client) -> CommandResults: """ Creates a Lambda function from AWS. Args: args (dict): A dictionary containing the command arguments. aws_client (boto3 client): The AWS client used to delete the function. Returns: CommandResults: An object containing the result of the creation operation. """ output_headers = [ "FunctionName", "FunctionArn", "Runtime", "Role", "Handler", "CodeSize", "Description", "Timeout", "MemorySize", "Version", "PackageType", "LastModified", "VpcConfig", ] kwargs = prepare_create_function_kwargs(args) res = aws_client.create_function(**kwargs) outputs = {key: res.get(key) for key in output_headers} readable_outputs = outputs.copy() vpc_config = readable_outputs.pop("VpcConfig") readable_outputs.update( { "SubnetIds": vpc_config.get("SubnetIds"), "SecurityGroupIds": vpc_config.get("SecurityGroupIds"), "VpcId": vpc_config.get("VpcId"), "Ipv6AllowedForDualStack": vpc_config.get("Ipv6AllowedForDualStack"), } ) readable_output = tableToMarkdown(name="Create Function", t=readable_outputs, headerTransform=pascalToSpace) return CommandResults( outputs=outputs, raw_response=res, outputs_prefix="AWS.Lambda.Functions", outputs_key_field="FunctionArn", readable_output=readable_output, ) def publish_layer_version_command(args: dict[str, str], aws_client) -> CommandResults: """ Creates an Lambda layer from a ZIP archive. Args: args (dict): A dictionary containing the command arguments. aws_client (boto3 client): The AWS client used to delete the function. Returns: CommandResults: An object containing the result of the deletion operation as a readable output in Markdown format. """ output_headers = [ "LayerVersionArn", "LayerArn", "Description", "CreatedDate", "Version", "CompatibleRuntimes", "CompatibleArchitectures", ] content = {} s3_bucket = args.get("s3-bucket") s3_key = args.get("s3-key") s3_object_version = args.get("s3-object-version") if zip_file := args.get("zip-file"): file_path = demisto.getFilePath(zip_file).get("path") content["ZipFile"] = read_zip_to_bytes(file_path) elif s3_bucket and s3_key and s3_object_version: content["S3Bucket"] = s3_bucket content["S3Key"] = s3_key content["S3ObjectVersion"] = s3_object_version else: raise DemistoException("Either zip-file or a combination of s3-bucket, s3-key and s3-object-version must be provided.") kwargs = { "LayerName": args.get("layer-name"), "Description": args.get("description", ""), "Content": content, "CompatibleRuntimes": argToList(args.get("compatible-runtimes")), "CompatibleArchitectures": argToList(args.get("compatible-architectures")), } res = aws_client.publish_layer_version(**kwargs) readable_output = tableToMarkdown(name="Publish Layer Version", t=res, headers=output_headers, headerTransform=pascalToSpace) outputs = {key: res.get(key) for key in output_headers} return CommandResults( outputs=remove_empty_elements(outputs), raw_response=res, outputs_prefix="AWS.Lambda.Layers", outputs_key_field="LayerVersionArn", readable_output=readable_output, ) def delete_layer_version_command(args: dict[str, str], aws_client) -> CommandResults: """ Deletes a version of a Lambda layer. Args: args (dict): A dictionary containing the command arguments. aws_client (boto3 client): The AWS client used to delete the function. Returns: CommandResults: An object containing the result of the deletion operation as a readable output in Markdown format. """ layer_name = args.get("layer-name") version_number = arg_to_number(args.get("version-number")) kwargs = {"LayerName": layer_name, "VersionNumber": version_number} aws_client.delete_layer_version(**kwargs) # raises on error return CommandResults(readable_output=f"Deleted version number {version_number} of {layer_name} Successfully") def list_layer_version_command(args, aws_client): """ Lists the version of an Lambda layer. Args: args (dict): A dictionary containing the command arguments. aws_client (boto3 client): The AWS client used to delete the function. Returns: CommandResults: An object containing the result of the list operation. """ kwargs = { "LayerName": args.get("layer-name"), "CompatibleRuntime": args.get("compatible-runtime"), "Marker": args.get("token"), "MaxItems": arg_to_number(args.get("limit")), "CompatibleArchitecture": args.get("compatible-architecture"), } res = aws_client.list_layer_versions(**remove_empty_elements(kwargs)) outputs = { "AWS.Lambda.Layers(val.LayerVersionArn && val.LayerVersionArn == obj.LayerVersionArn)": res.get("LayerVersions"), "AWS.Lambda(true)": {"LayerVersionsNextToken": res.get("NextMarker")}, } readable_output = tableToMarkdown(name="Layer Version List", t=res.get("LayerVersions"), headerTransform=pascalToSpace) return CommandResults(outputs=remove_empty_elements(outputs), raw_response=res, readable_output=readable_output) """TEST FUNCTION""" def test_function(aws_client): response = aws_client.list_functions() if response["ResponseMetadata"]["HTTPStatusCode"] == 200: demisto.results("ok") def main(): params = demisto.params() command = demisto.command() args = demisto.args() aws_default_region = params.get("defaultRegion") aws_role_arn = params.get("roleArn") aws_role_session_name = params.get("roleSessionName") aws_role_session_duration = params.get("sessionDuration") aws_role_policy = None aws_access_key_id = params.get("credentials", {}).get("identifier") or params.get("access_key") aws_secret_access_key = params.get("credentials", {}).get("password") or params.get("secret_key") verify_certificate = not params.get("insecure", True) timeout = params.get("timeout") retries = params.get("retries") or 5 sts_endpoint_url = params.get("sts_endpoint_url") or None endpoint_url = params.get("endpoint_url") or None validate_params(aws_default_region, aws_role_arn, aws_role_session_name, aws_access_key_id, aws_secret_access_key) aws_client = AWSClient( aws_default_region, aws_role_arn, aws_role_session_name, aws_role_session_duration, aws_role_policy, aws_access_key_id, aws_secret_access_key, verify_certificate, timeout, retries, sts_endpoint_url=sts_endpoint_url, endpoint_url=endpoint_url, ) aws_client = config_aws_session(args, aws_client) try: match command: case "test-module": test_function(aws_client) case "aws-lambda-get-function": get_function(args, aws_client) case "aws-lambda-list-functions": list_functions(aws_client) case "aws-lambda-list-aliases": list_aliases(args, aws_client) case "aws-lambda-invoke": return_results(invoke(args, aws_client)) case "aws-lambda-remove-permission": remove_permission(args, aws_client) case "aws-lambda-get-account-settings": get_account_settings(args, aws_client) case "aws-lambda-get-policy": return_results(get_policy_command(args, aws_client)) case "aws-lambda-list-versions-by-function": return_results(list_versions_by_function_command(args, aws_client)) case "aws-lambda-get-function-url-config": return_results(get_function_url_config_command(args, aws_client)) case "aws-lambda-get-function-configuration": return_results(get_function_configuration_command(args, aws_client)) case "aws-lambda-delete-function-url-config": return_results(delete_function_url_config_command(args, aws_client)) case "aws-lambda-delete-function": return_results(delete_function_command(args, aws_client)) case "aws-lambda-create-function": return_results(create_function_command(args, aws_client)) case "aws-lambda-publish-layer-version": return_results(publish_layer_version_command(args, aws_client)) case "aws-lambda-delete-layer-version": return_results(delete_layer_version_command(args, aws_client)) case "aws-lambda-list-layer-version": return_results(list_layer_version_command(args, aws_client)) case _: raise NotImplementedError(f"Command {command} is not implemented") except Exception as e: return_error(f"Error has occurred in the AWS Lambda Integration: {type(e)}\n {e!s}") # python2 uses __builtin__ python3 uses builtins if __name__ in ("__main__", "__builtin__", "builtins"): main()