Skip to content

Commit d5ed5df

Browse files
authored
Adding EventInvokeConfig support for Function (#92)
Issue #, if available: **Summary** Adding support to configure `EventInvokeConfig` for a `function` in ACK. **Description** This PR adds support for `EventInvokeConfig` permitted by Lambda API operations in ACK. To implement this functionality I added `EventInvokeConfig` as an inline property to a `function`. Thus the user can directly set configurations for async invocation (EventInvokeConfig) while creating a function. The user can edit the following code to create `eventInvokeConfig` along with `function`. ``` apiVersion: lambda.services.k8s.aws/v1alpha1 kind: Function metadata: name: $FUNCTION_NAME annotations: services.k8s.aws/region: $AWS_REGION spec: name: $FUNCTION_NAME code: s3Bucket: $BUCKET_NAME s3Key: $LAMBDA_FILE_NAME functionEventInvokeConfig: destinationConfig: onSuccess: destination: $ON_SUCCESS_DESTINATION onFailure: destination: $ON_FAILURE_DESTINATION maximumEventAgeInSeconds: $MAXIMUM_EVENT_AGE_IN_SECONDS maximumRetryAttempts: $MAXIMUM_RETRY_ATTEMPTS role: $LAMBDA_ROLE runtime: python3.9 handler: main description: function created by ACK lambda-controller e2e tests ``` This PR includes both implementation code and e2e tests. **Acknowledgement** By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent db54010 commit d5ed5df

18 files changed

+458
-12
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2023-05-15T23:18:19Z"
3-
build_hash: 8f3ba427974fd6e769926778d54834eaee3b81a3
2+
build_date: "2023-06-07T18:16:37Z"
3+
build_hash: dcb9fd6c564ce817a48abd6f7b9ee4308aa1d13f
44
go_version: go1.19
5-
version: v0.26.1
6-
api_directory_checksum: a9fcef68210dd72b4b2e37052f2c1a9e971326c6
5+
version: v0.26.1-4-gdcb9fd6
6+
api_directory_checksum: ca34c731b281f29e80984c872002e220ddee5133
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.181
99
generator_config_info:
10-
file_checksum: 095af1082df5c34cdc12296dc085bc6b2b7eadb9
10+
file_checksum: d53a6ae44af0a12af854385908c6e09355b3a126
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/function.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/generator.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ resources:
6161
from:
6262
operation: GetFunction
6363
path: Configuration.Layers
64+
FunctionEventInvokeConfig:
65+
from:
66+
operation: PutFunctionEventInvokeConfig
67+
path: .
6468
renames:
6569
operations:
6670
CreateFunction:

apis/v1alpha1/types.go

Lines changed: 15 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/lambda.services.k8s.aws_functions.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,37 @@ spec:
116116
type: string
117117
type: object
118118
type: array
119+
functionEventInvokeConfig:
120+
properties:
121+
destinationConfig:
122+
description: A configuration object that specifies the destination
123+
of an event after Lambda processes it.
124+
properties:
125+
onFailure:
126+
description: A destination for events that failed processing.
127+
properties:
128+
destination:
129+
type: string
130+
type: object
131+
onSuccess:
132+
description: A destination for events that were processed
133+
successfully.
134+
properties:
135+
destination:
136+
type: string
137+
type: object
138+
type: object
139+
functionName:
140+
type: string
141+
maximumEventAgeInSeconds:
142+
format: int64
143+
type: integer
144+
maximumRetryAttempts:
145+
format: int64
146+
type: integer
147+
qualifier:
148+
type: string
149+
type: object
119150
handler:
120151
description: The name of the method within your code that Lambda calls
121152
to run your function. Handler is required if the deployment package

generator.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ resources:
6161
from:
6262
operation: GetFunction
6363
path: Configuration.Layers
64+
FunctionEventInvokeConfig:
65+
from:
66+
operation: PutFunctionEventInvokeConfig
67+
path: .
6468
renames:
6569
operations:
6670
CreateFunction:

helm/crds/lambda.services.k8s.aws_functions.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,37 @@ spec:
116116
type: string
117117
type: object
118118
type: array
119+
functionEventInvokeConfig:
120+
properties:
121+
destinationConfig:
122+
description: A configuration object that specifies the destination
123+
of an event after Lambda processes it.
124+
properties:
125+
onFailure:
126+
description: A destination for events that failed processing.
127+
properties:
128+
destination:
129+
type: string
130+
type: object
131+
onSuccess:
132+
description: A destination for events that were processed
133+
successfully.
134+
properties:
135+
destination:
136+
type: string
137+
type: object
138+
type: object
139+
functionName:
140+
type: string
141+
maximumEventAgeInSeconds:
142+
format: int64
143+
type: integer
144+
maximumRetryAttempts:
145+
format: int64
146+
type: integer
147+
qualifier:
148+
type: string
149+
type: object
119150
handler:
120151
description: The name of the method within your code that Lambda calls
121152
to run your function. Handler is required if the deployment package

helm/templates/deployment.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ spec:
1818
app.kubernetes.io/instance: {{ .Release.Name }}
1919
template:
2020
metadata:
21+
{{- if .Values.deployment.annotations }}
2122
annotations:
2223
{{- range $key, $value := .Values.deployment.annotations }}
2324
{{ $key }}: {{ $value | quote }}
2425
{{- end }}
26+
{{- end }}
2527
labels:
2628
app.kubernetes.io/name: {{ include "app.name" . }}
2729
app.kubernetes.io/instance: {{ .Release.Name }}
@@ -104,11 +106,19 @@ spec:
104106
value: {{ include "aws.credentials.path" . }}
105107
- name: AWS_PROFILE
106108
value: {{ .Values.aws.credentials.profile }}
109+
{{- end }}
110+
{{- if .Values.deployment.extraEnvVars -}}
111+
{{ toYaml .Values.deployment.extraEnvVars | nindent 8 }}
112+
{{- end }}
107113
volumeMounts:
114+
{{- if .Values.aws.credentials.secretName }}
108115
- name: {{ .Values.aws.credentials.secretName }}
109116
mountPath: {{ include "aws.credentials.secret_mount_path" . }}
110117
readOnly: true
111118
{{- end }}
119+
{{- if .Values.deployment.extraVolumeMounts -}}
120+
{{ toYaml .Values.deployment.extraVolumeMounts | nindent 12 }}
121+
{{- end }}
112122
securityContext:
113123
allowPrivilegeEscalation: false
114124
privileged: false
@@ -133,9 +143,12 @@ spec:
133143
hostIPC: false
134144
hostNetwork: false
135145
hostPID: false
136-
{{ if .Values.aws.credentials.secretName -}}
137146
volumes:
147+
{{- if .Values.aws.credentials.secretName -}}
138148
- name: {{ .Values.aws.credentials.secretName }}
139149
secret:
140150
secretName: {{ .Values.aws.credentials.secretName }}
141151
{{ end -}}
152+
{{- if .Values.deployment.extraVolumes }}
153+
{{ toYaml .Values.deployment.extraVolumes | indent 8}}
154+
{{- end }}

helm/values.schema.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@
5858
},
5959
"priorityClassName": {
6060
"type": "string"
61+
},
62+
"extraVolumeMounts": {
63+
"type": "array"
64+
},
65+
"extraVolumes": {
66+
"type": "array"
67+
},
68+
"extraEnvVars": {
69+
"type": "array"
6170
}
6271
},
6372
"required": [

helm/values.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ deployment:
2828
# Which priorityClassName to set?
2929
# See: https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#pod-priority
3030
priorityClassName: ""
31+
extraVolumes: []
32+
extraVolumeMounts: []
33+
34+
# Additional server container environment variables
35+
#
36+
# You specify this manually like you would a raw deployment manifest.
37+
# This means you can bind in environment variables from secrets.
38+
#
39+
# e.g. static environment variable:
40+
# - name: DEMO_GREETING
41+
# value: "Hello from the environment"
42+
#
43+
# e.g. secret environment variable:
44+
# - name: USERNAME
45+
# valueFrom:
46+
# secretKeyRef:
47+
# name: mysecret
48+
# key: username
49+
extraEnvVars: []
50+
3151

3252
# If "installScope: cluster" then these labels will be applied to ClusterRole
3353
role:

pkg/resource/function/delta.go

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)