in src/Amazon.Lambda.Tools/Commands/GetFunctionConfigCommand.cs [52:135]
protected override async Task<bool> PerformActionAsync()
{
GetFunctionConfigurationResponse response;
try
{
response = await this.LambdaClient.GetFunctionConfigurationAsync(this.GetStringValueOrDefault(this.FunctionName, LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_NAME, true));
}
catch (Exception e)
{
throw new LambdaToolsException("Error getting configuration for Lambda function: " + e.Message, LambdaToolsException.LambdaErrorCode.LambdaGetConfiguration, e);
}
const int PAD_SIZE = 30;
this.Logger.WriteLine("Name:".PadRight(PAD_SIZE) + response.FunctionName);
this.Logger.WriteLine("Arn:".PadRight(PAD_SIZE) + response.FunctionArn);
if(!string.IsNullOrEmpty(response.Description))
this.Logger.WriteLine("Description:".PadRight(PAD_SIZE) + response.Description);
this.Logger.WriteLine("Package Type:".PadRight(PAD_SIZE) + response.PackageType);
if (response.PackageType == PackageType.Image)
{
if(response.ImageConfigResponse?.ImageConfig?.Command?.Count > 0)
this.Logger.WriteLine("Image Command:".PadRight(PAD_SIZE) + FormatAsJsonStringArray(response.ImageConfigResponse?.ImageConfig?.Command));
if (response.ImageConfigResponse?.ImageConfig?.EntryPoint?.Count > 0)
this.Logger.WriteLine("Image EntryPoint:".PadRight(PAD_SIZE) + FormatAsJsonStringArray(response.ImageConfigResponse?.ImageConfig?.EntryPoint));
if (!string.IsNullOrEmpty(response.ImageConfigResponse?.ImageConfig?.WorkingDirectory))
this.Logger.WriteLine("Image WorkingDirectory:".PadRight(PAD_SIZE) + response.ImageConfigResponse?.ImageConfig?.WorkingDirectory);
}
else
{
this.Logger.WriteLine("Runtime:".PadRight(PAD_SIZE) + response.Runtime);
this.Logger.WriteLine("Function Handler:".PadRight(PAD_SIZE) + response.Handler);
}
this.Logger.WriteLine("Last Modified:".PadRight(PAD_SIZE) + response.LastModified);
this.Logger.WriteLine("Memory Size:".PadRight(PAD_SIZE) + response.MemorySize);
this.Logger.WriteLine("Role:".PadRight(PAD_SIZE) + response.Role);
this.Logger.WriteLine("Timeout:".PadRight(PAD_SIZE) + response.Timeout);
this.Logger.WriteLine("Version:".PadRight(PAD_SIZE) + response.Version);
this.Logger.WriteLine("State:".PadRight(PAD_SIZE) + response.State);
if(!string.IsNullOrEmpty(response.StateReason))
this.Logger.WriteLine("State Reason:".PadRight(PAD_SIZE) + response.StateReason);
this.Logger.WriteLine("Last Update Status:".PadRight(PAD_SIZE) + response.LastUpdateStatus);
if (!string.IsNullOrEmpty(response.LastUpdateStatusReason))
this.Logger.WriteLine("Last Update Status Reason:".PadRight(PAD_SIZE) + response.LastUpdateStatusReason);
if (!string.IsNullOrEmpty(response.KMSKeyArn))
this.Logger.WriteLine("KMS Key ARN:".PadRight(PAD_SIZE) + response.KMSKeyArn);
else
this.Logger.WriteLine("KMS Key ARN:".PadRight(PAD_SIZE) + "(default) aws/lambda");
if(!string.IsNullOrEmpty(response.DeadLetterConfig?.TargetArn))
{
this.Logger.WriteLine("Dead Letter Target:".PadRight(PAD_SIZE) + response.DeadLetterConfig.TargetArn);
}
if (response.Environment?.Variables?.Count > 0)
{
StringBuilder sb = new StringBuilder();
foreach(var kvp in response.Environment.Variables)
{
if (sb.Length > 0)
sb.Append(";");
sb.Append($"{kvp.Key}={kvp.Value}");
}
this.Logger.WriteLine("Environment Vars:".PadRight(PAD_SIZE) + sb);
}
if (response.VpcConfig != null && !string.IsNullOrEmpty(response.VpcConfig.VpcId))
{
this.Logger.WriteLine("VPC Config");
this.Logger.WriteLine(" VPC: ".PadRight(22) + response.VpcConfig.VpcId);
this.Logger.WriteLine(" Security Groups: ".PadRight(22) + string.Join(",", response.VpcConfig?.SecurityGroupIds));
this.Logger.WriteLine(" Subnets: ".PadRight(22) + string.Join(",", response.VpcConfig?.SubnetIds));
}
return true;
}