Skip to content

Commit 68e348e

Browse files
authored
Add ability to reference role created by iam-controller (#100)
**Issue #, if available:** aws-controllers-k8s/community#1835 **Description of changes:** Adds ability to use `roleRef` instead of `role` to reference an IAM role created by the `iam-controller`. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 24be866 commit 68e348e

File tree

14 files changed

+183
-10
lines changed

14 files changed

+183
-10
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2023-06-28T18:32:11Z"
2+
build_date: "2023-07-14T21:15:00Z"
33
build_hash: e9b68590da73ce9143ba1e4361cebdc1d876c81e
4-
go_version: go1.19
4+
go_version: go1.20.5
55
version: v0.26.1-7-ge9b6859
6-
api_directory_checksum: 5f162746e8495943dae5e96f48f4a3ab887b5be5
6+
api_directory_checksum: 5d5c7aea8863c47e7303cc870aad4250267d93d2
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.181
99
generator_config_info:
10-
file_checksum: ed4abfc994c2c47465801d301604c584bd743d41
10+
file_checksum: dfaa004dd9551888415d54b3006e115cef3dbef3
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/function.go

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

apis/v1alpha1/generator.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ resources:
3939
resource: Key
4040
path: Status.ACKResourceMetadata.ARN
4141
service_name: kms
42+
Role:
43+
references:
44+
resource: Role
45+
path: Status.ACKResourceMetadata.ARN
46+
service_name: iam
4247
Name:
4348
is_primary_key: true
4449
is_required: true
@@ -189,4 +194,4 @@ resources:
189194
Version: VersionNumber
190195
ListLayerVersions:
191196
input_fields:
192-
Version: VersionNumber
197+
Version: VersionNumber

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 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_functions.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,19 @@ spec:
235235
description: The Amazon Resource Name (ARN) of the function's execution
236236
role.
237237
type: string
238+
roleRef:
239+
description: "AWSResourceReferenceWrapper provides a wrapper around
240+
*AWSResourceReference type to provide more user friendly syntax
241+
for references using 'from' field Ex: APIIDRef: \n from: name: my-api"
242+
properties:
243+
from:
244+
description: AWSResourceReference provides all the values necessary
245+
to reference another k8s resource for finding the identifier(Id/ARN/Name)
246+
properties:
247+
name:
248+
type: string
249+
type: object
250+
type: object
238251
runtime:
239252
description: The identifier of the function's runtime (https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html).
240253
Runtime is required if the deployment package is a .zip file archive.
@@ -321,7 +334,6 @@ spec:
321334
required:
322335
- code
323336
- name
324-
- role
325337
type: object
326338
status:
327339
description: FunctionStatus defines the observed state of Function

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+
- iam.services.k8s.aws
64+
resources:
65+
- roles
66+
verbs:
67+
- get
68+
- list
69+
- apiGroups:
70+
- iam.services.k8s.aws
71+
resources:
72+
- roles/status
73+
verbs:
74+
- get
75+
- list
6276
- apiGroups:
6377
- kafka.services.k8s.aws
6478
resources:

generator.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ resources:
3939
resource: Key
4040
path: Status.ACKResourceMetadata.ARN
4141
service_name: kms
42+
Role:
43+
references:
44+
resource: Role
45+
path: Status.ACKResourceMetadata.ARN
46+
service_name: iam
4247
Name:
4348
is_primary_key: true
4449
is_required: true
@@ -189,4 +194,4 @@ resources:
189194
Version: VersionNumber
190195
ListLayerVersions:
191196
input_fields:
192-
Version: VersionNumber
197+
Version: VersionNumber

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/iam-controller v1.2.3
78
github.com/aws-controllers-k8s/kafka-controller v0.0.0-20230615185632-102279061de1
89
github.com/aws-controllers-k8s/kms-controller v0.1.2
910
github.com/aws-controllers-k8s/mq-controller v0.0.22

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/iam-controller v1.2.3 h1:Vzz7/qxhcfkPrqn64Oi0tbvHetyiEto3gQuvpCSpECA=
44+
github.com/aws-controllers-k8s/iam-controller v1.2.3/go.mod h1:c7WaFwq2tIJjwpZhnuCYQ2ISzzMUJLTisPv92lim8sk=
4345
github.com/aws-controllers-k8s/kafka-controller v0.0.0-20230615185632-102279061de1 h1:NvmtIsm6fVoGUOvMfevONJETf+PtRWAiD3XzZBtQ2WA=
4446
github.com/aws-controllers-k8s/kafka-controller v0.0.0-20230615185632-102279061de1/go.mod h1:BHW00DFtXtugpsyn0nN0YdP32xmCN5p3lIJYP+Y0iVY=
4547
github.com/aws-controllers-k8s/kms-controller v0.1.2 h1:9lb98jspqOpFpmIFHOJ6pRnOkC8kDEPIgTAb5QnVGZo=

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,19 @@ spec:
235235
description: The Amazon Resource Name (ARN) of the function's execution
236236
role.
237237
type: string
238+
roleRef:
239+
description: "AWSResourceReferenceWrapper provides a wrapper around
240+
*AWSResourceReference type to provide more user friendly syntax
241+
for references using 'from' field Ex: APIIDRef: \n from: name: my-api"
242+
properties:
243+
from:
244+
description: AWSResourceReference provides all the values necessary
245+
to reference another k8s resource for finding the identifier(Id/ARN/Name)
246+
properties:
247+
name:
248+
type: string
249+
type: object
250+
type: object
238251
runtime:
239252
description: The identifier of the function's runtime (https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html).
240253
Runtime is required if the deployment package is a .zip file archive.
@@ -321,7 +334,6 @@ spec:
321334
required:
322335
- code
323336
- name
324-
- role
325337
type: object
326338
status:
327339
description: FunctionStatus defines the observed state of Function

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+
- iam.services.k8s.aws
79+
resources:
80+
- roles
81+
verbs:
82+
- get
83+
- list
84+
- apiGroups:
85+
- iam.services.k8s.aws
86+
resources:
87+
- roles/status
88+
verbs:
89+
- get
90+
- list
7791
- apiGroups:
7892
- kafka.services.k8s.aws
7993
resources:

pkg/resource/function/delta.go

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

pkg/resource/function/references.go

Lines changed: 98 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)