Skip to content

fix: attach policies to Role on create #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apis/v1alpha1/ack-generate-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ack_generate_info:
build_date: "2025-05-02T16:46:04Z"
build_hash: f8dc5330705b3752ce07dce0ac831161fd4cb14f
go_version: go1.24.2
version: v0.45.0
build_date: "2025-05-08T19:50:19Z"
build_hash: a82538df1333319f8ec1d603f6cf293aefc46e1b
go_version: go1.24.1
version: v0.45.0-3-ga82538d
api_directory_checksum: 7e1c19231d3275a1147157f6943a7391953f7001
api_version: v1alpha1
aws_sdk_go_version: v1.32.6
Expand Down
4 changes: 4 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ spec:
- "$(ACK_WATCH_NAMESPACE)"
- --watch-selectors
- "$(ACK_WATCH_SELECTORS)"
- --reconcile-resources
- "$(RECONCILE_RESOURCES)"
- --deletion-policy
- "$(DELETION_POLICY)"
{{- if .Values.leaderElection.enabled }}
Expand Down Expand Up @@ -107,6 +109,8 @@ spec:
value: {{ include "ack-iam-controller.watch-namespace" . }}
- name: ACK_WATCH_SELECTORS
value: {{ .Values.watchSelectors }}
- name: RECONCILE_RESOURCES
value: {{ join "," .Values.reconcile.resources | quote }}
- name: DELETION_POLICY
value: {{ .Values.deletionPolicy }}
- name: LEADER_ELECTION_NAMESPACE
Expand Down
8 changes: 8 additions & 0 deletions helm/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@
},
"resourceMaxConcurrentSyncs": {
"type": "object"
},
"resources": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of resource kinds to reconcile. If empty, all resources will be reconciled.",
"default": []
}
},
"type": "object"
Expand Down
11 changes: 11 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ reconcile:
# An object representing the reconcile max concurrent syncs configuration for each specific
# resource.
resourceMaxConcurrentSyncs: {}

# Set the value of resources to specify which resource kinds to reconcile.
# If empty, all resources will be reconciled.
# If specified, only the listed resource kinds will be reconciled.
resources:
- Groups
- Instanceprofiles
- Openidconnectproviders
- Policies
- Roles
- Users

serviceAccount:
# Specifies whether a service account should be created
Expand Down
12 changes: 12 additions & 0 deletions pkg/resource/role/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions templates/hooks/role/sdk_create_post_set_output.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,16 @@
ko.Spec.AssumeRolePolicyDocument = &doc
}
}
for _, p := range desired.ko.Spec.Policies {
err := rm.addManagedPolicy(ctx, &resource{ko}, p)
if err != nil {
return &resource{ko}, err
}
}
for n, p := range desired.ko.Spec.InlinePolicies {
err := rm.addInlinePolicy(ctx, &resource{ko}, n, p)
if err != nil {
return &resource{ko}, err
}
}
ackcondition.SetSynced(&resource{ko}, corev1.ConditionFalse, nil, nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we can move it into a hook, just a suggestion.