@@ -41,12 +41,6 @@ export class Services extends Stack {
41
41
constructor ( scope : Construct , id : string , props ?: StackProps ) {
42
42
super ( scope , id , props ) ;
43
43
44
- var isEventEngine = 'false' ;
45
- if ( this . node . tryGetContext ( 'is_event_engine' ) != undefined )
46
- {
47
- isEventEngine = this . node . tryGetContext ( 'is_event_engine' ) ;
48
- }
49
-
50
44
const stackName = id ;
51
45
52
46
// Create SQS resource to send Pet adoption messages to
@@ -342,7 +336,8 @@ export class Services extends Stack {
342
336
defaultCapacityInstance : ec2 . InstanceType . of ( ec2 . InstanceClass . T3 , ec2 . InstanceSize . MEDIUM ) ,
343
337
secretsEncryptionKey : secretsKey ,
344
338
version : KubernetesVersion . of ( '1.28' ) ,
345
- kubectlLayer : new KubectlLayer ( this , 'kubectl' )
339
+ kubectlLayer : new KubectlLayer ( this , 'kubectl' ) ,
340
+ authenticationMode : eks . AuthenticationMode . API_AND_CONFIG_MAP ,
346
341
} ) ;
347
342
348
343
const clusterSG = ec2 . SecurityGroup . fromSecurityGroupId ( this , 'ClusterSG' , cluster . clusterSecurityGroupId ) ;
@@ -445,60 +440,16 @@ export class Services extends Stack {
445
440
446
441
loadBalancerserviceaccount . assumeRolePolicy ?. addStatements ( loadBalancer_trustRelationship ) ;
447
442
448
- // Fix for EKS Dashboard access
449
-
450
- const dashboardRoleYaml = yaml . loadAll ( readFileSync ( "./resources/dashboard.yaml" , "utf8" ) ) as Record < string , any > [ ] ;
451
-
452
- const dashboardRoleArn = this . node . tryGetContext ( 'dashboard_role_arn' ) ;
453
- if ( ( dashboardRoleArn != undefined ) && ( dashboardRoleArn . length > 0 ) ) {
454
- const role = iam . Role . fromRoleArn ( this , "DashboardRoleArn" , dashboardRoleArn , { mutable :false } ) ;
455
- cluster . awsAuth . addRoleMapping ( role , { groups :[ "dashboard-view" ] } ) ;
456
- }
457
-
458
- if ( isEventEngine === 'true' )
459
- {
460
-
461
- var c9Env = new Cloud9Environment ( this , 'Cloud9Environment' , {
462
- vpcId : theVPC . vpcId ,
463
- subnetId : theVPC . publicSubnets [ 0 ] . subnetId ,
464
- cloud9OwnerArn : "assumed-role/WSParticipantRole/Participant" ,
465
- templateFile : __dirname + "/../../../../cloud9-cfn.yaml"
466
-
467
- } ) ;
468
-
469
- var c9role = c9Env . c9Role ;
470
-
471
- // Dynamically check if AWSCloud9SSMAccessRole and AWSCloud9SSMInstanceProfile exists
472
- const c9SSMRole = new iam . Role ( this , 'AWSCloud9SSMAccessRole' , {
473
- path : '/service-role/' ,
474
- roleName : 'AWSCloud9SSMAccessRole' ,
475
- assumedBy : new iam . CompositePrincipal ( new iam . ServicePrincipal ( "ec2.amazonaws.com" ) , new iam . ServicePrincipal ( "cloud9.amazonaws.com" ) ) ,
476
- managedPolicies : [ iam . ManagedPolicy . fromAwsManagedPolicyName ( "AWSCloud9SSMInstanceProfile" ) , iam . ManagedPolicy . fromAwsManagedPolicyName ( "AdministratorAccess" ) ]
477
- } ) ;
478
-
479
- const teamRole = iam . Role . fromRoleArn ( this , 'TeamRole' , "arn:aws:iam::" + stack . account + ":role/WSParticipantRole" ) ;
480
- cluster . awsAuth . addRoleMapping ( teamRole , { groups :[ "dashboard-view" ] } ) ;
481
-
482
-
483
- if ( c9role != undefined ) {
484
- cluster . awsAuth . addMastersRole ( iam . Role . fromRoleArn ( this , 'c9role' , c9role . attrArn , { mutable : false } ) ) ;
485
- }
486
-
487
-
488
- }
489
-
490
443
const eksAdminArn = this . node . tryGetContext ( 'admin_role' ) ;
491
444
if ( ( eksAdminArn != undefined ) && ( eksAdminArn . length > 0 ) ) {
492
- const role = iam . Role . fromRoleArn ( this , "ekdAdminRoleArn" , eksAdminArn , { mutable :false } ) ;
493
- cluster . awsAuth . addMastersRole ( role )
445
+ const adminRole = iam . Role . fromRoleArn ( this , "ekdAdminRoleArn" , eksAdminArn , { mutable :false } ) ;
446
+ cluster . grantAccess ( 'TeamRoleAccess' , adminRole . roleArn , [
447
+ eks . AccessPolicy . fromAccessPolicyName ( 'AmazonEKSClusterAdminPolicy' , {
448
+ accessScopeType : eks . AccessScopeType . CLUSTER
449
+ } )
450
+ ] ) ;
494
451
}
495
452
496
- const dahshboardManifest = new eks . KubernetesManifest ( this , "k8sdashboardrbac" , {
497
- cluster : cluster ,
498
- manifest : dashboardRoleYaml
499
- } ) ;
500
-
501
-
502
453
var xRayYaml = yaml . loadAll ( readFileSync ( "./resources/k8s_petsite/xray-daemon-config.yaml" , "utf8" ) ) as Record < string , any > [ ] ;
503
454
504
455
xRayYaml [ 0 ] . metadata . annotations [ "eks.amazonaws.com/role-arn" ] = new CfnJson ( this , "xray_Role" , { value : `${ xrayserviceaccount . roleArn } ` } ) ;
0 commit comments