You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/releases/v0.5.0-beta1.md
+1
Original file line number
Diff line number
Diff line change
@@ -2,4 +2,5 @@ This release introduces the following:
2
2
3
3
- .NET Templates are here! Install via `dotnet new -i Lambdajection.Templates`. Templates are available for both projects and options.
4
4
- IDisposable and IAsyncDisposable Lambdas are now fully supported. Disposers will be called at the end of each invocation. If you implement both IDisposable and IAsyncDisposable, DisposeAsync will be preferred.
5
+
- Added an example for custom config factories.
5
6
- Upgrades Roslyn to 3.7.0 (via CodeGeneration.Roslyn) for latest bug and security fixes, along with increased nullability checks. Addressed changes around new possible null references.
Copy file name to clipboardExpand all lines: README.md
+3
Original file line number
Diff line number
Diff line change
@@ -241,6 +241,8 @@ namespace Your.Namespace
241
241
}
242
242
```
243
243
244
+
See the [full example here](./examples/CustomConfiguration/README.md).
245
+
244
246
### 4.5. Adding Options
245
247
246
248
You can add an options section by defining a class for that section, and annotating it with the [LambdaOptions attribute](src/Attributes/LambdaOptionsAttribute.cs). If any options are in encrypted form, add the [Encrypted attribute](src/Encryption/EncryptedAttribute.cs) to that property. When the options are requested, the [IDecryptionService](src/Encryption/IDecryptionService.cs) singleton in the container will be used to decrypt those properties. The [default decryption service](src/Encryption/DefaultDecryptionService.cs) uses KMS to decrypt values.
1. Create a new netcoreapp3.1 and add the following packages:
15
+
16
+
- Lambdajection
17
+
18
+
2. Create a [ConfigFactory](./ConfigFactory.cs) that enables file-based configuration. Set the ConfigFactory argument in the Lambda Handler attribute to point to your config factory's type.
19
+
20
+
21
+
3. Create a [Config / Options](./Config.cs) class that will be used to hold your configuration items. Inject this class into your handler and read values from it inside the `Handle` method.
22
+
23
+
24
+
4. Add a [Startup Class](Startup.cs) and configure any services that will be injected into your Lambda Handler in here.
25
+
26
+
5. Create a [CloudFormation template](cloudformation.template.yml) for your Lambda.
27
+
- Note that we are using the serverless transform in the example, however using the transform is optional.
28
+
29
+
## How it Works
30
+
31
+
1. During a build, the generator will use your config factory in place of [the default one](../../src/Core/LambdaConfigFactory.cs). The type of this class is added as a generic argument to the [Lambda Host](../../src/Core/LambdaHost.cs).
32
+
2. When the lambda is run, the [Lambda Host Builder](../../src/Core/LambdaHostBuilder.cs) will create a new instance of your config factory and create a configuration instance using that factory. That config instance will then be added to the service collection / provider passed to the lambda host as well as your startup class.
0 commit comments