|
| 1 | +import { CfnFunction } from './lambda.generated'; |
| 2 | + |
| 3 | +/** |
| 4 | + * Specify the runtime update mode. |
| 5 | + */ |
| 6 | +export class RuntimeManagementMode { |
| 7 | + /** |
| 8 | + * Automatically update to the most recent and secure runtime version using Two-phase runtime version rollout. |
| 9 | + * We recommend this mode for most customers so that you always benefit from runtime updates. |
| 10 | + */ |
| 11 | + public static readonly AUTO = new RuntimeManagementMode('Auto'); |
| 12 | + /** |
| 13 | + * When you update your function, Lambda updates the runtime of your function to the most recent and secure runtime version. |
| 14 | + * This approach synchronizes runtime updates with function deployments, |
| 15 | + * giving you control over when Lambda applies runtime updates. |
| 16 | + * With this mode, you can detect and mitigate rare runtime update incompatibilities early. |
| 17 | + * When using this mode, you must regularly update your functions to keep their runtime up to date. |
| 18 | + */ |
| 19 | + public static readonly FUNCTION_UPDATE = new RuntimeManagementMode('Function update'); |
| 20 | + /** |
| 21 | + * You specify a runtime version in your function configuration. |
| 22 | + * The function uses this runtime version indefinitely. |
| 23 | + * In the rare case in which a new runtime version is incompatible with an existing function, |
| 24 | + * you can use this mode to roll back your function to an earlier runtime version. |
| 25 | + */ |
| 26 | + public static manual(arn: string): RuntimeManagementMode { |
| 27 | + return new RuntimeManagementMode('Manual', arn); |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-runtimemanagementconfig.html |
| 32 | + */ |
| 33 | + readonly runtimeManagementConfig: CfnFunction.RuntimeManagementConfigProperty; |
| 34 | + |
| 35 | + protected constructor(public readonly mode: string, public readonly arn?: string) { |
| 36 | + if (arn) { |
| 37 | + this.runtimeManagementConfig = { |
| 38 | + runtimeVersionArn: arn, |
| 39 | + updateRuntimeOn: mode, |
| 40 | + }; |
| 41 | + } else { |
| 42 | + this.runtimeManagementConfig = { |
| 43 | + updateRuntimeOn: mode, |
| 44 | + }; |
| 45 | + } |
| 46 | + } |
| 47 | +} |
0 commit comments