Any tips on how to make lambda handler c# code more efficient from .NET perspective?
Some of the example questions I am trying to address:
1) WIll making lambda functions static increase reuse of Lambda context and improve performance?
2) If I make Functions class ( which has all lambda handlers) singleton class, will it improve performance?
3) If I make constant/readonly variables and share it across lambda functions, will it improve performance?
If anyone has any information, please suggest
Hi guys, I'm new to AWS and I've been trying to fix an issue I have with the appsettings.json... been looking for a fix for 3days now ..
I just wanted to know if there is a way to specify which Appsettings to use when deploying a .Net Core application? I have (Dev, Staging and Production) I'm using the Publish to Elastic Beanstalk in my Visual Studio 2017.
I am developing an app with UNITY 2017.2.3f1 and the aws-sdk-unity_3.3.396.2
S3 works fine which means that many elements are OK. The code works fine for MAC and Android
However when I try to post an element on DynamoDB with the following code
var rec = new Document();
rec["id"] = 1;//recName;
rec["Lat"] = 2;//Input.location.lastData.latitude;
rec["Long"] = 3;//Input.location.lastData.longitude;
rec["Time"] = 4;//recTime;
table.PutItemAsync(rec, (r) => {
Debug.Log("\n rec has been poted " + r.Exception + " *222444*****************");
textnotification.text = "Archivo subido con éxito";
Invoke("cleanText", 3);
butSender.interactable = false;
butPlayer.interactable = true;
butRecorder.interactable = true;
hasnotbeensent = false;
});
it complains with the following error.
System.InvalidOperationException: No converter configured for type System.String
at Amazon.DynamoDBv2.ConverterCache.GetConverter (System.Type type) [0x00000] in <filename unknown>:0
at Amazon.DynamoDBv2.DynamoDBEntryConversion.ConvertToEntry (System.Type inputType, System.Object value) [0x00000] in <filename unknown>:0
at Amazon.DynamoDBv2.DocumentModel.UnconvertedDynamoDBEntry.ConvertToAttributeValue (Amazon.DynamoDBv2.DocumentModel.AttributeConversionConfig conversionConfig) [0x00000] in <filename unknown>:0
at Amazon.DynamoDBv2.DocumentModel.Document.ToAttributeMap (Amazon.DynamoDBv2.DynamoDBEntryConversion conversion, IEnumerable1 epochAttributes) [0x00000] in <filename unknown>:0
at Amazon.DynamoDBv2.DocumentModel.Table.PutItemHelper (Amazon.DynamoDBv2.DocumentModel.Document doc, Amazon.DynamoDBv2.DocumentModel.PutItemOperationConfig config) [0x00000] in <filename unknown>:0
at Amazon.DynamoDBv2.DynamoDBAsyncExecutor+<>c__DisplayClass1_0
1[T].<ExecuteAsync>b__0 (System.Object state) [0x00000] in <filename unknown>:0 * *
I think it is a Bug but I am not sure.
Hi all, I have one question and I can't find answer for it (SO, google, numerous tries my own code). How can I instantiate AmazonCognitoIdentityProviderClient?
I'm using .net core 2 and the code is really simple:
var credentials = new EnvironmentVariablesAWSCredentials();
CognitoProvider = new AmazonCognitoIdentityProviderClient(credentials, RegionEndpoint.EUCentral1);
But AmazonCognitoIdentityProviderClient throws exceptionSystem.IO.FileNotFoundException: 'Could not find file 'C:\Users\USER\.aws\credentials'.'
I know what it means, but why is it throwing that exception? I want to use environment credentials and they are all right (EnvironmentVariablesAWSCredentials doesnt complain and Environment.GetEnvironmentVariable on AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY returns correct values).
I can provide the file on my local environment but I can't do that on production. How am I suppose to pass credentials to cognito client? Am I missing something?
"AWS": {
"Region": ...,
"AccessKeyId": ...,
"SecretAccessKey":...
},
but I cannot create a s3 client
opConfig.QueryFilter =
new List<ScanCondition>
{
new ScanCondition("Status", ScanOperator.Equal, 10),
new ScanCondition("Status", ScanOperator.Equal, 4),
new ScanCondition("PlanType", ScanOperator.Equal, "SML"),
//new ScanCondition("NormalRoadConditions", ScanOperator.Equal, true)
};
List<string> partionKeys = new List<string>() { "52049E96-14FA-4960-B3CE-F7400C4AC6CD", "01F3DF08-4D0F-4E92-BBE3-8E46BA77E73B", "52117BC1-7256-4C36-868E-465DB2178286" };
if (!string.IsNullOrEmpty(TableName))
{
AWSConfigsDynamoDB.Context.TypeMappings[typeof(Plan)] = new Amazon.Util.TypeMapping(typeof(Plan), TableName);
}
var start = DateTime.Now;
int totalCount = 0;
var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 };
var client = new AmazonDynamoDBClient(new StoredProfileAWSCredentials("sandbox"), RegionEndpoint.EUWest1);
DbContext = new DynamoDBContext(client, config);
var opConfig = new DynamoDBOperationConfig { IndexName = "OrganizationId-Created-index" };
opConfig.QueryFilter =
new List<ScanCondition>
{
new ScanCondition("Status", ScanOperator.Equal, 10),
new ScanCondition("Status", ScanOperator.Equal, 4),
new ScanCondition("PlanType", ScanOperator.Equal, "SML"),
//new ScanCondition("NormalRoadConditions", ScanOperator.Equal, true)
};
foreach (var partionKey in partionKeys)
{
var result = Program.DbContext.QueryAsync<Plan>(partionKey.ToLower(), opConfig);
while (!result.IsDone)
{
var plans = result.GetNextSetAsync().Result;
totalCount += plans.Count;
}
}
public async Task<string> FunctionHandler(S3Event evnt, ILambdaContext context)
{
var serviceCollection = new ServiceCollection();
ConfigureServices(serviceCollection);
// service provider
var serviceProvider = serviceCollection.BuildServiceProvider();
// entry to run app
var service = serviceProvider.GetService<ApplicationService>();
return await service.LocalFunctionHandler(evnt, context);
}
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<Logger>();
services.AddSingleton<IAmazonS3>(s3 => new AmazonS3Client(Amazon.RegionEndpoint.USEast1));
services.AddSingleton<IAmazonBatch>(batch => new AmazonBatchClient(Amazon.RegionEndpoint.USEast1));
services.AddTransient<ApplicationService>();
}