Interface ILambdaFunctionDependencyProvider
The ILambdaFunctionDependencyProvider interface provides all the required dependencies for ALambdaFunction instances. This interface follows the Dependency Provider pattern where all side-effecting methods and properties must be provided by an outside implementation.
Namespace: LambdaSharp
Assembly: LambdaSharp.dll
Syntax
public interface ILambdaFunctionDependencyProvider
Properties
ConfigSource
Retrieves the ILambdaConfigSource instance used for initializing the Lambda function.
Declaration
ILambdaConfigSource ConfigSource { get; }
Property Value
Type | Description |
---|---|
ILambdaConfigSource | The ILambdaConfigSource instance. |
DebugLoggingEnabled
The DebugLoggingEnabled property indicates if the requests received and responses emitted by this Lambda function should be shown in the CloudWatch logs. This can be useful to determine check for issues caused by inconsistencies in serialization or deserialization.
Declaration
bool DebugLoggingEnabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Boolean indicating if requests and responses are logged |
UtcNow
Retrieves the current date-time in UTC timezone.
Declaration
DateTime UtcNow { get; }
Property Value
Type | Description |
---|---|
System.DateTime | Current System.DateTime in UTC timezone |
Methods
DecryptSecretAsync(Byte[], Dictionary<String, String>, CancellationToken)
Decrypt a sequence of bytes with an optional encryption context. The Lambda function
requires permission to use the kms:Decrypt
operation on the KMS key used to
encrypt the original message.
Declaration
Task<byte[]> DecryptSecretAsync(byte[] secretBytes, Dictionary<string, string> encryptionContext = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | secretBytes | Array containing the encrypted bytes. |
System.Collections.Generic.Dictionary<System.String, System.String> | encryptionContext | An optional encryption context. Can be |
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Byte[]> | The task object representing the asynchronous operation. |
EncryptSecretAsync(Byte[], String, Dictionary<String, String>, CancellationToken)
Encrypt a sequence of bytes using the specified KMS key. The Lambda function requires
permission to use the kms:Encrypt
opeartion on the specified KMS key.
Declaration
Task<byte[]> EncryptSecretAsync(byte[] plaintextBytes, string encryptionKeyId, Dictionary<string, string> encryptionContext = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | plaintextBytes | Array containing plaintext byte to encrypt. |
System.String | encryptionKeyId | The KMS key ID used encrypt the plaintext bytes. |
System.Collections.Generic.Dictionary<System.String, System.String> | encryptionContext | An optional encryption context. Can be |
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Byte[]> | The task object representing the asynchronous operation. |
Log(String)
Write a message to the log stream. In production, this should be the CloudWatch log associated with the Lambda function.
Declaration
void Log(string message)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | Message to write to the log stream. |
SendEventAsync(DateTimeOffset, String, String, String, String, IEnumerable<String>, CancellationToken)
Send a CloudWatch event with optional event details and resources it applies to. This event will be forwarded to the default EventBridge by LambdaSharp.Core (requires Core Services to be enabled).
Declaration
Task SendEventAsync(DateTimeOffset timestamp, string eventbus, string source, string detailType, string detail, IEnumerable<string> resources, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.DateTimeOffset | timestamp | The timestamp of the event. |
System.String | eventbus | The event bus that will receive the event. |
System.String | source | The source application of the event. |
System.String | detailType | Free-form string used to decide what fields to expect in the event detail. |
System.String | detail | Optional data-structure serialized as JSON string. There is no other schema imposed. The data-structure may contain fields and nested subobjects. |
System.Collections.Generic.IEnumerable<System.String> | resources | Optional AWS or custom resources, identified by unique identifier (e.g. ARN), which the event primarily concerns. Any number, including zero, may be present. |
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendMessageToQueueAsync(String, String, IEnumerable<KeyValuePair<String, String>>, CancellationToken)
Send a message to the specified SQS queue. The Lambda function requires sqs:SendMessage
permission
on the specified SQS queue.
Declaration
Task SendMessageToQueueAsync(string queueUrl, string message, IEnumerable<KeyValuePair<string, string>> messageAttributes = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | queueUrl | The SQS queue URL. |
System.String | message | The message to send. |
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.String>> | messageAttributes | Optional attributes for the message. |
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | The task object representing the asynchronous operation. |