3434# Allow some mappings in the aws-auth ConfigMap to exist without being defined
3535# in a IamIdentityMapping object.
3636IGNORED_CM_IDENTITIES = [
37- # EKS worker nodes
38- # "system:node:{{EC2PrivateDNSName }}",
37+ # Fargate profile mapping
38+ "system:node:{{SessionName }}" ,
3939]
4040
4141
@@ -49,7 +49,7 @@ async def update_mapping(old, new, diff, **_) -> None:
4949 await delete_mapping (old ["spec" ])
5050 await create_mapping (new ["spec" ], diff )
5151
52- # @kopf.on.update(GROUP, VERSION, PLURAL)
52+
5353@kopf .on .create (GROUP , VERSION , PLURAL )
5454async def create_mapping (spec : dict , diff : list , ** _ ) -> None :
5555 """Create/update an identity mapping in the aws-auth configmap with the corresponding IamIdentityMapping.
@@ -223,11 +223,11 @@ def ensure_identity(identity: dict, identity_list: list) -> list:
223223
224224 for i , existing_identity in enumerate (identity_list ):
225225 # Handle existing identity
226- if "rolearn" in existing_identity and existing_identity [ "rolearn" ] == identity [ "rolearn" ] :
226+ if "rolearn" in existing_identity and existing_identity . get ( "rolearn" ) == identity . get ( "rolearn" ) :
227227 identity_list [i ] = identity
228228 return identity_list
229-
230- if "userarn" in existing_identity and existing_identity [ "userarn" ] == identity [ "userarn" ] :
229+
230+ if "userarn" in existing_identity and existing_identity . get ( "userarn" ) == identity . get ( "userarn" ) :
231231 identity_list [i ] = identity
232232 return identity_list
233233
@@ -245,11 +245,11 @@ def delete_identity(identity: dict, identity_list: list) -> list:
245245 """
246246
247247 for i , existing_user in enumerate (identity_list ):
248- if "rolearn" in existing_user and existing_user [ "rolearn" ] == identity [ "rolearn" ] :
248+ if "rolearn" in existing_user and existing_user . get ( "rolearn" ) == identity . get ( "rolearn" ) :
249249 del identity_list [i ]
250250 return identity_list
251251
252- if "userarn" in existing_user and existing_user [ "userarn" ] == identity [ "userarn" ] :
252+ if "userarn" in existing_user and existing_user . get ( "userarn" ) == identity . get ( "userarn" ) :
253253 del identity_list [i ]
254254 return identity_list
255255
0 commit comments