using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json; using Amazon.Lambda.Core; using Amazon.Lambda.APIGatewayEvents; using System; using Amazon.SecurityToken; using Amazon.SecurityToken.Model; // Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. [assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] namespace STS { public class Function { public async Task FunctionHandler(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context) { var client = new AmazonSecurityTokenServiceClient(); var response = await client.GetCallerIdentityAsync(new GetCallerIdentityRequest {}); string account = response.Account; var body = new Dictionary { { "message", "hello world" }, {"account", account} }; return new APIGatewayProxyResponse { Body = JsonConvert.SerializeObject(body), StatusCode = 200, Headers = new Dictionary { { "Content-Type", "application/json" } } }; } } }