@@ -36,10 +36,10 @@ export = {
36
36
const user = new iam . User ( stack , 'user' ) ;
37
37
38
38
// WHEN
39
- cluster . awsAuth . addRoleMapping ( role , { groups : [ 'role-group1' ] , username : 'roleuser' } ) ;
40
- cluster . awsAuth . addRoleMapping ( role , { groups : [ 'role-group2' , 'role-group3' ] } ) ;
41
- cluster . awsAuth . addUserMapping ( user , { groups : [ 'user-group1' , 'user-group2' ] } ) ;
42
- cluster . awsAuth . addUserMapping ( user , { groups : [ 'user-group1' , 'user-group2' ] , username : 'foo' } ) ;
39
+ cluster . awsAuth . addRoleMapping ( role , { groups : [ 'role-group1' ] , username : 'roleuser' } ) ;
40
+ cluster . awsAuth . addRoleMapping ( role , { groups : [ 'role-group2' , 'role-group3' ] } ) ;
41
+ cluster . awsAuth . addUserMapping ( user , { groups : [ 'user-group1' , 'user-group2' ] } ) ;
42
+ cluster . awsAuth . addUserMapping ( user , { groups : [ 'user-group1' , 'user-group2' ] , username : 'foo' } ) ;
43
43
cluster . awsAuth . addAccount ( '112233' ) ;
44
44
cluster . awsAuth . addAccount ( '5566776655' ) ;
45
45
@@ -71,31 +71,62 @@ export = {
71
71
"Arn"
72
72
]
73
73
} ,
74
- "\\\",\\\"groups\\\":[\\\"role-group2\\\",\\\"role-group3\\\"]}]\",\"mapUsers\":\"[{\\\"userarn\\\":\\\"arn: " ,
74
+ "\\\",\\\"groups\\\":[\\\"role-group2\\\",\\\"role-group3\\\"]}]\",\"mapUsers\":\"[{\\\"userarn\\\":\\\"" ,
75
75
{
76
- Ref : "AWS::Partition"
76
+ "Fn::GetAtt" : [
77
+ "user2C2B57AE" ,
78
+ "Arn"
79
+ ]
77
80
} ,
78
- ":iam:us-east-1: " ,
81
+ "\\\",\\\"groups\\\":[\\\"user-group1\\\",\\\"user-group2\\\"]},{\\\"userarn\\\":\\\" " ,
79
82
{
80
- Ref : "AWS::AccountId"
83
+ "Fn::GetAtt" : [
84
+ "user2C2B57AE" ,
85
+ "Arn"
86
+ ]
81
87
} ,
82
- ":user/" ,
88
+ "\\\",\\\"username\\\":\\\"foo\\\",\\\"groups\\\":[\\\"user-group1\\\",\\\"user-group2\\\"]}]\",\"mapAccounts\":\"[\\\"112233\\\",\\\"5566776655\\\"]\"}}]"
89
+ ]
90
+ ]
91
+ }
92
+ } ) ) ;
93
+
94
+ test . done ( ) ;
95
+ } ,
96
+
97
+ 'imported users and roles can be also be used' ( test : Test ) {
98
+ // GIVEN
99
+ const { stack } = testFixtureNoVpc ( ) ;
100
+ const cluster = new Cluster ( stack , 'Cluster' ) ;
101
+ const role = iam . Role . fromRoleArn ( stack , 'imported-role' , 'arn:aws:iam::123456789012:role/S3Access' ) ;
102
+ const user = iam . User . fromUserName ( stack , 'import-user' , 'MyUserName' ) ;
103
+
104
+ // WHEN
105
+ cluster . awsAuth . addRoleMapping ( role , { groups : [ 'group1' ] } ) ;
106
+ cluster . awsAuth . addUserMapping ( user , { groups : [ 'group2' ] } ) ;
107
+
108
+ // THEN
109
+ expect ( stack ) . to ( haveResource ( KubernetesResource . RESOURCE_TYPE , {
110
+ Manifest : {
111
+ "Fn::Join" : [
112
+ "" ,
113
+ [
114
+ "[{\"apiVersion\":\"v1\",\"kind\":\"ConfigMap\",\"metadata\":{\"name\":\"aws-auth\",\"namespace\":\"kube-system\"},\"data\":{\"mapRoles\":\"[{\\\"rolearn\\\":\\\"" ,
83
115
{
84
- Ref : "user2C2B57AE"
116
+ "Fn::GetAtt" : [
117
+ "ClusterDefaultCapacityInstanceRole3E209969" ,
118
+ "Arn"
119
+ ]
85
120
} ,
86
- "\\\",\\\"groups\\\":[\\\"user-group1 \\\",\\\"user-group2 \\\"]},{\\\"userarn\\\":\\\"arn:" ,
121
+ "\\\",\\\"username\\\":\\\"system:node:{{EC2PrivateDNSName}}\\\",\\\" groups\\\":[\\\"system:bootstrappers \\\",\\\"system:nodes \\\"]},{\\\"rolearn\\\":\\\"arn:aws:iam::123456789012:role/S3Access\\\",\\\"groups\\\":[\\\"group1\\\"]}]\",\"mapUsers\":\"[ {\\\"userarn\\\":\\\"arn:" ,
87
122
{
88
123
Ref : "AWS::Partition"
89
124
} ,
90
- ":iam:us-east-1 :" ,
125
+ ":iam::" ,
91
126
{
92
127
Ref : "AWS::AccountId"
93
128
} ,
94
- ":user/" ,
95
- {
96
- Ref : "user2C2B57AE"
97
- } ,
98
- "\\\",\\\"username\\\":\\\"foo\\\",\\\"groups\\\":[\\\"user-group1\\\",\\\"user-group2\\\"]}]\",\"mapAccounts\":\"[\\\"112233\\\",\\\"5566776655\\\"]\"}}]"
129
+ ":user/MyUserName\\\",\\\"groups\\\":[\\\"group2\\\"]}]\",\"mapAccounts\":\"[]\"}}]"
99
130
]
100
131
]
101
132
}
0 commit comments