@@ -37,7 +37,7 @@ const defaultProps: HelmAddOnUserProps & S3CSIDriverAddOnProps = {
3737 name : S3_CSI_DRIVER ,
3838 namespace : "kube-system" ,
3939 release : S3_CSI_DRIVER_RELEASE ,
40- version : "2.4.0 " ,
40+ version : "2.4.1 " ,
4141 repository : "https://awslabs.github.io/mountpoint-s3-csi-driver" ,
4242 createNamespace : false ,
4343 bucketNames : [ ] ,
@@ -55,40 +55,38 @@ export class S3CSIDriverAddOn extends HelmAddOn {
5555 }
5656
5757 deploy ( clusterInfo : ClusterInfo ) : Promise < Construct > {
58- // Create service account and policy
5958 const cluster = clusterInfo . cluster ;
59+
60+ // Create namespace
61+ if ( this . options . createNamespace ) {
62+ createNamespace ( this . options . namespace ! , cluster , true ) ;
63+ }
64+
65+ // Let Helm create the node SA with RBAC bindings
66+ const chartValues = populateValues ( this . options ) ;
67+ const s3CsiDriverChart = this . addHelmChart ( clusterInfo , chartValues , true , true ) ;
68+
69+ // Overwrite the Helm-created SA with IRSA annotation (fires after chart)
6070 const serviceAccount = cluster . addServiceAccount ( S3_CSI_DRIVER_SA , {
6171 name : S3_CSI_DRIVER_SA ,
6272 namespace : this . options . namespace ,
73+ overwriteServiceAccount : true
6374 } ) ;
6475
6576 const s3BucketPolicy = new iam . Policy ( cluster , S3_DRIVER_POLICY , {
6677 statements :
6778 getS3DriverPolicyStatements ( this . options . bucketNames , this . options . kmsArns ?? [ ] )
6879 } ) ;
6980 serviceAccount . role . attachInlinePolicy ( s3BucketPolicy ) ;
70-
71- // Create namespace
72- if ( this . options . createNamespace ) {
73- const ns = createNamespace ( this . options . namespace ! , cluster , true ) ;
74- serviceAccount . node . addDependency ( ns ) ;
75- }
76-
77- // setup value for helm chart
78- const chartValues = populateValues ( this . options , serviceAccount . serviceAccountName ) ;
7981
80- const s3CsiDriverChart = this . addHelmChart ( clusterInfo , chartValues , true , true ) ;
81- s3CsiDriverChart . node . addDependency ( serviceAccount ) ;
82+ serviceAccount . node . addDependency ( s3CsiDriverChart ) ;
8283 return Promise . resolve ( s3CsiDriverChart ) ;
8384 }
8485}
8586
86- function populateValues ( helmOptions : S3CSIDriverAddOnProps , serviceAccountName : string ) : any {
87+ function populateValues ( helmOptions : S3CSIDriverAddOnProps ) : any {
8788 const values = helmOptions . values ?? { } ;
88- // Only configure the node service account (which needs S3 access)
89- setPath ( values , 'node.serviceAccount.create' , false ) ;
90- setPath ( values , 'node.serviceAccount.name' , serviceAccountName ) ;
91- // Let Helm create the controller service account (no S3 access needed)
89+ setPath ( values , 'node.serviceAccount.create' , true ) ;
9290 setPath ( values , 'controller.serviceAccount.create' , true ) ;
9391 setPath ( values , 'node.tolerateAllTaints' , true ) ;
9492 return values ;
0 commit comments