Skip to content
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

Update iamserviceaccount role policies #3064

Merged
merged 19 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions integration/tests/crud/creategetdelete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ var _ = Describe("(Integration) Create, Get, Scale & Delete", func() {
})
})

Context("create and delete iamserviceaccounts", func() {
Context("create, update, and delete iamserviceaccounts", func() {
var (
cfg *api.ClusterConfig
ctl *eks.ClusterProvider
Expand All @@ -346,7 +346,7 @@ var _ = Describe("(Integration) Create, Get, Scale & Delete", func() {
Expect(err).ShouldNot(HaveOccurred())
})

It("should enable OIDC and create two iamserviceaccounts", func() {
It("should enable OIDC, create two iamserviceaccounts and update the policies", func() {
{
exists, err := oidc.CheckProviderExists()
Expect(err).ShouldNot(HaveOccurred())
Expand Down Expand Up @@ -414,6 +414,19 @@ var _ = Describe("(Integration) Create, Get, Scale & Delete", func() {
Expect(sa.Annotations).To(HaveKey(api.AnnotationEKSRoleARN))
Expect(sa.Annotations[api.AnnotationEKSRoleARN]).To(MatchRegexp("^arn:aws:iam::.*:role/eksctl-" + truncate(params.ClusterName) + ".*$"))
}

cmds = []Cmd{
params.EksctlUpdateCmd.WithArgs(
"iamserviceaccount",
"--cluster", params.ClusterName,
"--name", "app-cache-access",
"--namespace", "app1",
"--attach-policy-arn", "arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess",
"--approve",
),
}

Expect(cmds).To(RunSuccessfully())
})

It("should list both iamserviceaccounts", func() {
Expand Down
18 changes: 18 additions & 0 deletions pkg/actions/iam/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package iam

import (
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"github.com/weaveworks/eksctl/pkg/ctl/cmdutils"
"github.com/weaveworks/eksctl/pkg/kubernetes"
)

func (a *Manager) CreateIAMServiceAccount(iamServiceAccounts []*api.ClusterIAMServiceAccount, plan bool) error {
taskTree := a.stackManager.NewTasksToCreateIAMServiceAccounts(iamServiceAccounts, a.oidcManager, kubernetes.NewCachedClientSet(a.clientSet), false)
taskTree.PlanMode = plan

err := doTasks(taskTree)

cmdutils.LogPlanModeWarning(plan && len(iamServiceAccounts) > 0)

return err
}
291 changes: 291 additions & 0 deletions pkg/actions/iam/fakes/fake_stack_manager.go

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