Skip to content

Commit c202355

Browse files
Merge pull request openshift#7650 from pawanpinjarkar/add-kms-encryption-keys
OCPBUGS-13664: Add KMS encryption keys if provided
2 parents ace0161 + bb1c44d commit c202355

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

pkg/asset/installconfig/aws/permissions.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const (
3838

3939
// PermissionDeleteHostedZone is a set of permissions required when the installer destroys a route53 hosted zone.
4040
PermissionDeleteHostedZone PermissionGroup = "delete-hosted-zone"
41+
42+
// PermissionKMSEncryptionKeys is an additional set of permissions required when the installer uses user provided kms encryption keys.
43+
PermissionKMSEncryptionKeys PermissionGroup = "kms-encryption-keys"
4144
)
4245

4346
var permissions = map[PermissionGroup][]string{
@@ -244,6 +247,16 @@ var permissions = map[PermissionGroup][]string{
244247
PermissionDeleteHostedZone: {
245248
"route53:DeleteHostedZone",
246249
},
250+
PermissionKMSEncryptionKeys: {
251+
"kms:Decrypt",
252+
"kms:Encrypt",
253+
"kms:GenerateDataKey",
254+
"kms:GenerateDataKeyWithoutPlainText",
255+
"kms:DescribeKey",
256+
"kms:RevokeGrant",
257+
"kms:CreateGrant",
258+
"kms:ListGrants",
259+
},
247260
}
248261

249262
// ValidateCreds will try to create an AWS session, and also verify that the current credentials

pkg/asset/installconfig/platformpermscheck.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import (
55
"fmt"
66

77
"github.com/pkg/errors"
8+
"github.com/sirupsen/logrus"
89

910
"github.com/openshift/installer/pkg/asset"
1011
awsconfig "github.com/openshift/installer/pkg/asset/installconfig/aws"
1112
gcpconfig "github.com/openshift/installer/pkg/asset/installconfig/gcp"
1213
powervsconfig "github.com/openshift/installer/pkg/asset/installconfig/powervs"
14+
"github.com/openshift/installer/pkg/types"
1315
"github.com/openshift/installer/pkg/types/alibabacloud"
1416
"github.com/openshift/installer/pkg/types/aws"
1517
"github.com/openshift/installer/pkg/types/azure"
@@ -47,8 +49,10 @@ func (a *PlatformPermsCheck) Generate(dependencies asset.Parents) error {
4749
dependencies.Get(ic)
4850

4951
if ic.Config.CredentialsMode != "" {
52+
logrus.Debug("CredentialsMode is set. Skipping platform permissions checks before attempting installation.")
5053
return nil
5154
}
55+
logrus.Debug("CredentialsMode is not set. Performing platform permissions checks before attempting installation.")
5256

5357
var err error
5458
platform := ic.Config.Platform.Name()
@@ -66,6 +70,23 @@ func (a *PlatformPermsCheck) Generate(dependencies asset.Parents) error {
6670
permissionGroups = append(permissionGroups, awsconfig.PermissionCreateHostedZone)
6771
}
6872

73+
var ec2RootVolume = aws.EC2RootVolume{}
74+
var awsMachinePoolUsingKMS, masterMachinePoolUsingKMS bool
75+
if ic.Config.AWS.DefaultMachinePlatform != nil && ic.Config.AWS.DefaultMachinePlatform.EC2RootVolume != ec2RootVolume {
76+
awsMachinePoolUsingKMS = len(ic.Config.AWS.DefaultMachinePlatform.EC2RootVolume.KMSKeyARN) != 0
77+
}
78+
if ic.Config.ControlPlane != nil &&
79+
ic.Config.ControlPlane.Name == types.MachinePoolControlPlaneRoleName &&
80+
ic.Config.ControlPlane.Platform.AWS != nil &&
81+
ic.Config.ControlPlane.Platform.AWS.EC2RootVolume != ec2RootVolume {
82+
masterMachinePoolUsingKMS = len(ic.Config.ControlPlane.Platform.AWS.EC2RootVolume.KMSKeyARN) != 0
83+
}
84+
// Add KMS encryption keys, if provided.
85+
if awsMachinePoolUsingKMS || masterMachinePoolUsingKMS {
86+
logrus.Debugf("Adding %s to the group of permissions to validate", awsconfig.PermissionKMSEncryptionKeys)
87+
permissionGroups = append(permissionGroups, awsconfig.PermissionKMSEncryptionKeys)
88+
}
89+
6990
// Add delete permissions for non-C2S installs.
7091
if !aws.IsSecretRegion(ic.Config.AWS.Region) {
7192
permissionGroups = append(permissionGroups, awsconfig.PermissionDeleteBase)

0 commit comments

Comments
 (0)