in adot/utils/soak/soak.py [0:0]
def enableLambdaInsight(function_name):
lambdaClient = boto3.client("lambda")
lambdaInsightLayerArn = lambdaInsightArnMap[boto3.Session().region_name]
response = lambdaClient.get_function_configuration(FunctionName=function_name)
print("Lambda function has layers: {}".format(response["Layers"]))
arnList = []
for item in response["Layers"]:
arn = item["Arn"]
arnList.append(arn)
if arn == lambdaInsightLayerArn:
print("LambdaInsight has been enabled, no need enable again.")
return
arnList.append(lambdaInsightLayerArn)
lambdaClient.update_function_configuration(
FunctionName=function_name, Layers=arnList
)
response = lambdaClient.get_function_configuration(FunctionName=function_name)
print("Enable LambdaInsight {}".format(response["Layers"]))