Skip to main content

GetRoleFromSecurityContext

Retrieves the IAM role from the security context of the task execution metadata, falling back to annotations for backward compatibility if no role is found in the security context.

def GetRoleFromSecurityContext(
roleKey: string,
taskExecutionMetadata: core2.TaskExecutionMetadata
) - > string

Retrieves the IAM role from the provided security context or task execution metadata. This function first attempts to get the role from the security context's 'RunAs' field and falls back to annotations for backward compatibility if no role is found.

Parameters

NameTypeDescription
roleKeystringThe key used to look up the role within the task execution metadata's annotations if the role is not found in the security context.
taskExecutionMetadatacore2.TaskExecutionMetadataThe metadata object containing security context information and annotations from which the role will be extracted.

Returns

TypeDescription
stringThe IAM role string associated with the security context or annotations.