Skip to content

Commit 6aba0d1

Browse files
authored
support User.inlinePolicies (#65)
Adds support for inline policies for User resources. The new User.Spec.inlinePolicies field is a map[string]*string, keyed by the inline policy name and valued with the inline policy document (serialized JSON string). Inline policies are actually added and removed from a User using different IAM API calls than their managed policy counterparts. Whereas managed policies (contained in the User.Spec.Policies field) are attached and detached from the User using the AttachPolicyUser and DetachUserPolicy API calls, the inline policies are attached and detached from the User using the AddUserPolicy and DeleteUserPolicy API calls. Yes, this is confusing and why I hadn't actually included inline policies from the very beginning (I did not realize these were separate things and separate API calls). Similar to managed policies, all inline policies are removed from the User prior to user deletion. Issue aws-controllers-k8s/community#1644 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent b80ed37 commit 6aba0d1

18 files changed

+364
-55
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2023-02-28T16:33:37Z"
2+
build_date: "2023-03-01T17:11:46Z"
33
build_hash: d0f3d78cbea8061f822cbceac3786128f091efe6
44
go_version: go1.19.4
55
version: v0.24.2
6-
api_directory_checksum: 68b20a583916eac0fb007442dfd1220a9fb9722d
6+
api_directory_checksum: a80aaa82b401436fd8d17f6b1fe931e484c62fb8
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.93
99
generator_config_info:
10-
file_checksum: 52f2fa89ae0904d8c6d22fafaa472d1943b23211
10+
file_checksum: a20dca352b45b74c1ea3bd4350ce3ab9d2d5c23e
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ resources:
177177
# policy document.
178178
InlinePolicies:
179179
type: map[string]*string
180-
late_initialize: {}
181180
Tags:
182181
compare:
183182
is_ignored: true
@@ -260,6 +259,14 @@ resources:
260259
references:
261260
resource: Policy
262261
path: Status.ACKResourceMetadata.ARN
262+
# These are policy documents that are added to the User using the
263+
# Put/DeleteUserPolicy APIs, as compared to the Attach/DetachUserPolicy
264+
# APIs that are for non-inline managed policies.
265+
#
266+
# The map key is the PolicyDocumentName and the map value is the JSON
267+
# policy document.
268+
InlinePolicies:
269+
type: map[string]*string
263270
Tags:
264271
compare:
265272
is_ignored: true

apis/v1alpha1/user.go

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

config/crd/bases/iam.services.k8s.aws_users.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ spec:
3838
response element in the following operations: \n * CreateUser \n * GetUser
3939
\n * ListUsers"
4040
properties:
41+
inlinePolicies:
42+
additionalProperties:
43+
type: string
44+
type: object
4145
name:
4246
description: "The name of the user to create. \n IAM user, group,
4347
role, and policy names must be unique within the account. Names

config/iam/recommended-inline-policy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,25 @@
2828
"iam:ListPolicyVersions",
2929
"iam:ListPolicyTags",
3030
"iam:ListAttachedGroupPolicies",
31+
"iam:GetGroupPolicy",
32+
"iam:PutGroupPolicy",
3133
"iam:AttachGroupPolicy",
3234
"iam:DetachGroupPolicy",
35+
"iam:DeleteGroupPolicy",
3336
"iam:ListAttachedRolePolicies",
37+
"iam:ListRolePolicies",
38+
"iam:GetRolePolicy",
39+
"iam:PutRolePolicy",
3440
"iam:AttachRolePolicy",
3541
"iam:DetachRolePolicy",
42+
"iam:DeleteRolePolicy",
3643
"iam:ListAttachedUserPolicies",
44+
"iam:ListUserPolicies",
45+
"iam:GetUserPolicy",
46+
"iam:PutUserPolicy",
3747
"iam:AttachUserPolicy",
3848
"iam:DetachUserPolicy",
49+
"iam:DeleteUserPolicy",
3950
"iam:ListRoleTags",
4051
"iam:ListUserTags",
4152
"iam:TagPolicy",

generator.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ resources:
259259
references:
260260
resource: Policy
261261
path: Status.ACKResourceMetadata.ARN
262+
# These are policy documents that are added to the User using the
263+
# Put/DeleteUserPolicy APIs, as compared to the Attach/DetachUserPolicy
264+
# APIs that are for non-inline managed policies.
265+
#
266+
# The map key is the PolicyDocumentName and the map value is the JSON
267+
# policy document.
268+
InlinePolicies:
269+
type: map[string]*string
262270
Tags:
263271
compare:
264272
is_ignored: true

helm/crds/iam.services.k8s.aws_users.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ spec:
3838
response element in the following operations: \n - CreateUser \n - GetUser
3939
\n - ListUsers"
4040
properties:
41+
inlinePolicies:
42+
additionalProperties:
43+
type: string
44+
type: object
4145
name:
4246
description: "The name of the user to create. \n IAM user, group,
4347
role, and policy names must be unique within the account. Names

pkg/resource/role/manager.go

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

pkg/resource/user/delta.go

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