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

Bug 1888464: add tag:UnTagResource perm for aws shared networks #4371

Merged
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
7 changes: 7 additions & 0 deletions pkg/asset/installconfig/aws/permissions.go
Expand Up @@ -25,6 +25,9 @@ const (

// PermissionDeleteNetworking is a set of permissions required when the installer destroys networking resources.
PermissionDeleteNetworking PermissionGroup = "delete-networking"

// PermissionDeleteSharedNetworking is a set of permissions required when the installer destroys resources from a shared-network cluster.
PermissionDeleteSharedNetworking PermissionGroup = "delete-shared-networking"
)

var permissions = map[PermissionGroup][]string{
Expand Down Expand Up @@ -215,6 +218,10 @@ var permissions = map[PermissionGroup][]string{
"ec2:DisassociateRouteTable",
"ec2:ReplaceRouteTableAssociation",
},
// Permissions required for deleting a cluster with shared network resources
PermissionDeleteSharedNetworking: {
"tag:UnTagResources",
},
}

// ValidateCreds will try to create an AWS session, and also verify that the current credentials
Expand Down
19 changes: 15 additions & 4 deletions pkg/asset/installconfig/platformpermscheck.go
Expand Up @@ -48,10 +48,21 @@ func (a *PlatformPermsCheck) Generate(dependencies asset.Parents) error {
platform := ic.Config.Platform.Name()
switch platform {
case aws.Name:
permissionGroups := []awsconfig.PermissionGroup{awsconfig.PermissionCreateBase, awsconfig.PermissionDeleteBase}
// If subnets are not provided in install-config.yaml, include network permissions
if len(ic.Config.AWS.Subnets) == 0 {
permissionGroups = append(permissionGroups, awsconfig.PermissionCreateNetworking, awsconfig.PermissionDeleteNetworking)
permissionGroups := []awsconfig.PermissionGroup{awsconfig.PermissionCreateBase}
usingExistingVPC := len(ic.Config.AWS.Subnets) != 0

if !usingExistingVPC {
permissionGroups = append(permissionGroups, awsconfig.PermissionCreateNetworking)
}

// Add delete permissions for non-C2S installs.
if !aws.C2SRegions.Has(ic.Config.AWS.Region) {
permissionGroups = append(permissionGroups, awsconfig.PermissionDeleteBase)
if usingExistingVPC {
permissionGroups = append(permissionGroups, awsconfig.PermissionDeleteSharedNetworking)
} else {
permissionGroups = append(permissionGroups, awsconfig.PermissionDeleteNetworking)
}
}

ssn, err := ic.AWS.Session(ctx)
Expand Down