Skip to content

Commit 4cf226f

Browse files
committed
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 4cf226f

28 files changed

+633
-14
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-27T21:57:38Z"
3+
build_hash: e9b68590da73ce9143ba1e4361cebdc1d876c81e
44
go_version: go1.19
5-
version: v0.26.1
6-
api_directory_checksum: a9fcef68210dd72b4b2e37052f2c1a9e971326c6
5+
version: v0.26.1-7-ge9b6859
6+
api_directory_checksum: 5326aa7650a3899230ee809563bea350169fdca4
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.181
99
generator_config_info:
10-
file_checksum: 095af1082df5c34cdc12296dc085bc6b2b7eadb9
10+
file_checksum: a9fdc0888330c561da4bf5f21d0f5afe48217935
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/event_source_mapping.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/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: 9 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:
@@ -113,6 +117,11 @@ resources:
113117
resource: Broker
114118
path: Status.BrokerID
115119
service_name: mq
120+
EventSourceARN:
121+
references:
122+
resource: Cluster
123+
path: Status.ACKResourceMetadata.ARN
124+
service_name: kafka
116125
UUID:
117126
is_primary_key: true
118127
FunctionName:

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: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/controller/main.go

Lines changed: 2 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_eventsourcemappings.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ spec:
9090
Streaming for Apache Kafka – The ARN of the cluster. \n * Amazon
9191
MQ – The ARN of the broker."
9292
type: string
93+
eventSourceRef:
94+
description: "AWSResourceReferenceWrapper provides a wrapper around
95+
*AWSResourceReference type to provide more user friendly syntax
96+
for references using 'from' field Ex: APIIDRef: \n from: name: my-api"
97+
properties:
98+
from:
99+
description: AWSResourceReference provides all the values necessary
100+
to reference another k8s resource for finding the identifier(Id/ARN/Name)
101+
properties:
102+
name:
103+
type: string
104+
type: object
105+
type: object
93106
filterCriteria:
94107
description: An object that defines the filter criteria that determine
95108
whether Lambda should process an event. For more information, see

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

config/rbac/cluster-role-controller.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ rules:
5959
verbs:
6060
- get
6161
- list
62+
- apiGroups:
63+
- kafka.services.k8s.aws
64+
resources:
65+
- clusters
66+
verbs:
67+
- get
68+
- list
69+
- apiGroups:
70+
- kafka.services.k8s.aws
71+
resources:
72+
- clusters/status
73+
verbs:
74+
- get
75+
- list
6276
- apiGroups:
6377
- kms.services.k8s.aws
6478
resources:

generator.yaml

Lines changed: 9 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:
@@ -113,6 +117,11 @@ resources:
113117
resource: Broker
114118
path: Status.BrokerID
115119
service_name: mq
120+
EventSourceARN:
121+
references:
122+
resource: Cluster
123+
path: Status.ACKResourceMetadata.ARN
124+
service_name: kafka
116125
UUID:
117126
is_primary_key: true
118127
FunctionName:

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.19
44

55
require (
66
github.com/aws-controllers-k8s/ec2-controller v0.0.21
7+
github.com/aws-controllers-k8s/kafka-controller v0.0.0-20230615185632-102279061de1
78
github.com/aws-controllers-k8s/kms-controller v0.1.2
89
github.com/aws-controllers-k8s/mq-controller v0.0.22
910
github.com/aws-controllers-k8s/runtime v0.26.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF
4040
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
4141
github.com/aws-controllers-k8s/ec2-controller v0.0.21 h1:5O7/9aED2Tl9OT0TL2rWrc1Ix5V1UxYEgDKAhvFhPJQ=
4242
github.com/aws-controllers-k8s/ec2-controller v0.0.21/go.mod h1:OMsmJeJ3iQZ1sJgs3hqnjBRnJ3hmTzJUO38W5rxnB5M=
43+
github.com/aws-controllers-k8s/kafka-controller v0.0.0-20230615185632-102279061de1 h1:NvmtIsm6fVoGUOvMfevONJETf+PtRWAiD3XzZBtQ2WA=
44+
github.com/aws-controllers-k8s/kafka-controller v0.0.0-20230615185632-102279061de1/go.mod h1:BHW00DFtXtugpsyn0nN0YdP32xmCN5p3lIJYP+Y0iVY=
4345
github.com/aws-controllers-k8s/kms-controller v0.1.2 h1:9lb98jspqOpFpmIFHOJ6pRnOkC8kDEPIgTAb5QnVGZo=
4446
github.com/aws-controllers-k8s/kms-controller v0.1.2/go.mod h1:6CoV0UMFd03EUF9dXgOTTScGdBhJzsWn9W0dw2n0kA4=
4547
github.com/aws-controllers-k8s/mq-controller v0.0.22 h1:XxFSQL9yaaiiuZ6E/fh/+Y9C+3DG2c5oXWG/4ZNwd1w=

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ spec:
9090
Streaming for Apache Kafka – The ARN of the cluster. \n - Amazon
9191
MQ – The ARN of the broker."
9292
type: string
93+
eventSourceRef:
94+
description: "AWSResourceReferenceWrapper provides a wrapper around
95+
*AWSResourceReference type to provide more user friendly syntax
96+
for references using 'from' field Ex: APIIDRef: \n from: name: my-api"
97+
properties:
98+
from:
99+
description: AWSResourceReference provides all the values necessary
100+
to reference another k8s resource for finding the identifier(Id/ARN/Name)
101+
properties:
102+
name:
103+
type: string
104+
type: object
105+
type: object
93106
filterCriteria:
94107
description: An object that defines the filter criteria that determine
95108
whether Lambda should process an event. For more information, see

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/cluster-role-controller.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ rules:
7474
verbs:
7575
- get
7676
- list
77+
- apiGroups:
78+
- kafka.services.k8s.aws
79+
resources:
80+
- clusters
81+
verbs:
82+
- get
83+
- list
84+
- apiGroups:
85+
- kafka.services.k8s.aws
86+
resources:
87+
- clusters/status
88+
verbs:
89+
- get
90+
- list
7791
- apiGroups:
7892
- kms.services.k8s.aws
7993
resources:

0 commit comments

Comments
 (0)