Cannot find a handler of type EndpointResolver in AWSSDKS3 - amazon-web-services

This is my issue:
I am updating AWS S3 nuget package from 3.7.1.2 to 3.7.101.25
Project details:
I have API that calls Class Library in which i am creating a AmazonS3Client. In version "3.7.1.2", its working fine. But in 3.7.101.25, i am getting below error.
Error:
System.InvalidOperationException HResult=0x80131509
Message=Cannot find a handler of type EndpointResolver
Source=AWSSDK.Core
Code:
var amazonS3Config = new AmazonS3Config()
{
MaxErrorRetry = maxRetryAttempts,
Timeout = TimeSpan.FromSeconds(requestTimeoutInSecond),
ServiceURL = serviceURL
}
s3Client = new AmazonS3Client(key, secret, amazonS3Config);

I was having the same issue where AWS looks like they opened up a ticket and resolved the issue. My issue was with AmazonKinesisClient but the same error.
https://github.com/aws/aws-xray-sdk-dotnet/issues/267 - same exception but for the AmazonDynamoDBClient.
This was resolved by installing the package AWSXRayRecorder.Handlers.AwsSdk v2.11.0

Related

TypeError: Cannot read property 'AwsCredentialsProvider' of undefined

Been trying to test out the aws-iot-device-sdk-v2 library for a bit. I am currently trying to test out the sample app provided by the AWS dev team. I am trying to test out the system incrementally. This is the code I have tested so far:
import { mqtt, auth, http, io, iot } from 'aws-iot-device-sdk-v2';
const client_bootstrap = new io.ClientBootstrap();
let config_builder = iot.AwsIotMqttConnectionConfigBuilder.new_with_websockets({
region: 'us-west-2',
credentials_provider: auth.AwsCredentialsProvider.newDefault(client_bootstrap)
});
config_builder.with_clean_session(false);
config_builder.with_endpoint('example.com');
config_builder.with_client_id(1);
const config = config_builder.build();
const client = new mqtt.MqttClient(client_bootstrap);
const connection = client.new_connection(config);
await connection.connect();
When running this on the AWS console, I am getting the following error:
TypeError: Cannot read property 'AwsCredentialsProvider' of undefined
Any idea what I'm doing wrong here?
Wasn't able to identify why I couldn't use AwsCredentialsProvider as expected but found a work-around. Instead, I was able to initialize the builder with const config_builder = iot.AwsIotMqttConnectionConfigBuilder.new_with_websockets();. Anyway, didn't figure out why I couldn't utilize AwsCredentialsProvider as expected. Might be something to look into if the dev team has time. 👍
I also encounter the same issue when running this example in browser and found the reason :
'aws-iot-device-sdk-v2' just import these 5 classes directly form aws-crt
https://github.com/aws/aws-iot-device-sdk-js-v2/blob/main/lib/index.ts
while in aws-crt, it's implementation for browser is in a sub folder ,
https://github.com/awslabs/aws-crt-nodejs/tree/main/lib/browserm, and it don't include 'auth' .
so if you run these example in browser, you need to import form aws-crt's subfolder, and skip 'auth':
import { mqtt, http, io, iot } from 'aws-crt/dist.browser/browser';

.Net 4.7 - Azure WebJob Project - JobHostConfiguration/RunAndBlock missing after NuGet updates

I had a working project with very dated NuGet package set for WebJob and storage. After a massive upgrade, I'm having three errors in this block only:
private static void Main()
{
var config = new JobHostConfiguration();
config.Queues.MaxDequeueCount = Convert.ToInt32(ConfigurationManager.AppSettings["MaxDequeueCount"]);
config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(Convert.ToInt32(ConfigurationManager.AppSettings["MaxPollingInterval"]));
config.Queues.BatchSize = Convert.ToInt32(ConfigurationManager.AppSettings["BatchSize"]); ;
config.NameResolver = new QueueNameResolver();
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
}
var host = new JobHost();
host.RunAndBlock();
}
Errors:
Error CS0246: The type or namespace name 'JobHostConfiguration' could not be found (are you missing a using directive or an assembly reference?) \Program.cs:11
Error CS7036: There is no argument given that corresponds to the required formal parameter 'options' of 'JobHost.JobHost(IOptions<JobHostOptions>, IJobHostContextFactory)' \Program.cs:23
Error CS1061: 'JobHost' does not contain a definition for 'RunAndBlock' and no accessible extension method 'RunAndBlock' accepting a first argument of type 'JobHost' could be found (are you missing a using directive or an assembly reference?) \Program.cs:24
All the helps and questions are showing .Net Core code. I'm on .Net Framework 4.7.2. How do I go about setting up this code in old framework?
If you want to Azure WebJob SDK V3, the JobHostConfiguration and JobHost have been removed. In version V3, the host is an implementation of IHost. For more details, please refer to here and here. Besides, please note that in version 3, you need to explicitly install the Storage binding extension required by the WebJobs SDK.
For example (Queue trigger in version 3)
#Install package Microsoft.Azure.WebJobs.Extensions.Storage 3.x
static async Task Main()
{
var builder = new HostBuilder();
builder.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices();
b.AddAzureStorage(a => {
a.BatchSize = 8;
a.NewBatchThreshold = 4;
a.MaxDequeueCount = 4;
a.MaxPollingInterval = TimeSpan.FromSeconds(15);
});
});
var host = builder.Build();
using (host)
{
await host.RunAsync();
}
}

Amazon SES - Connection

I'm trying to create a template on SES sandbox version. I use the following code but I'm getting the following error. Please help me fix this.
BasicAWSCredentials basicCreds = new BasicAWSCredentials("AXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXi");
AmazonSimpleEmailService client = null;
try{
client = AmazonSimpleEmailServiceClientBuilder.standard().withRegion(Regions.US_WEST_2).withCredentials(new AWSStaticCredentialsProvider(basicCreds)).build();
} catch (Exception ex){
logger.info(ex);
}
CreateTemplateRequest ctr = new CreateTemplateRequest();
Template template = new Template();
template.setTemplateName("Sample");
template.setSubjectPart("Sample Mail");
template.setTextPart("Test Mail from Template");
ctr.setTemplate(template);
client.createTemplate(ctr);
and the exception that I get is,
Exception in thread "main" java.lang.NoSuchFieldError: SIGNING_REGION
at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.executeCreateTemplate(AmazonSimpleEmailServiceClient.java:950)
at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.createTemplate(AmazonSimpleEmailServiceClient.java:932)
We are using ant build. If there is a jar problem please let me know which version of the jar I should be using.
Thanks in advance.

AWS parameter store access in lambda function

I'm trying to access the parameter store in an AWS lambda function. This is my code, pursuant to the documentation here: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SSM.html
var ssm = new AWS.SSM({apiVersion: '2014-11-06'});
var ssm_params1 = {
Name: 'XXXX', /* required */
WithDecryption: true
};
ssm.getParameter(ssm_params1, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else clientId = data.value;
});
Upon execution, I get the error:
"TypeError: ssm.getParameter is not a function"
Did amazon change this without changing the docs? Did this function move to another type of object?
Please check and try the latest version of the SDK. It is not the case that Amazon has ditched the getParameter method in favor of only getParameters. The fact is the method is getParameter, together with getParametersByPath, is newly added methods. Old version of SDK would not resolve these methods.
The answer here is that Amazon must have ditched the getParameter() method in favor of only maintaining one method getParameter(s)(). But they didn't update the documentation. That method seems to work just fine.
I have tried both getParameter and getParameters function, and both of them are working fine.
It could be possible that you are getting an error since you are passing "apiVersion: '2014-11-06'" to the SSM constructor.
Do not pass any apiVersion parameter to the function. It should work fine.
There seems to be a bug in AWS that is not including correct sdk version in certain environments. This can be confirmed by logging the sdk version used.
console.log("AWS-SDK Version: " + require('aws-sdk/package.json').version);
Including the required aws-sdk package solved the problem for us.
Try adding the following in package.json:
"aws-sdk": "^2.339.0"

Parse on AWS Issues

I have recently migrated my Parse.com service over to AWS Elastic Beanstalk running the Parse Server project from Github. Everything seems to be working fine except when I try to perform a query in Cloud Code.
Whenever I try to run a Parse.Query command I get the following exception at runtime.
Uncaught internal server error. [ReferenceError: atom is not defined] ReferenceError: atom is not defined
at /usr/local/lib/node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoTransform.js:559:78
at Array.map (native)
at transformConstraint (/usr/local/lib/node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoTransform.js:556:29)
at transformQueryKeyValue (/usr/local/lib/node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoTransform.js:193:7)
at transformWhere (/usr/local/lib/node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoTransform.js:215:15)
at MongoStorageAdapter.find (/usr/local/lib/node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoStorageAdapter.js:321:59)
at /usr/local/lib/node_modules/parse-server/lib/Controllers/DatabaseController.js:827:33
at run (/usr/local/lib/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:89:22)
at /usr/local/lib/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:102:28
at flush (/usr/local/lib/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:18:9)
Here is a sample of the Cloud Code I'm running. I must mention this code worked perfectly when hosted on Parse.com.
Parse.Cloud.define("getNumberOfUnreadMessages", function(request, response) {
var currentUser = request.params.user;
console.log("[getNumberOfUnreadMessages] Get User: " + JSON.stringify(currentUser));
var query = new Parse.Query("messages");
query.containedIn("toUser", [currentUser]);
query.equalTo("read", false);
query.find({
success: function(results) {
console.log('[getNumberOfUnreadMessages] Results: ' + results.length);
response.success(results.length);
},
error: function(e) {
response.error("[getNumberOfUnreadMessages] Error: " + JSON.stringify(e));
}
});
});
Any ideas what the problem could be?
Thanks!
So it turns out the issue has nothing todo with the server configuration. It was simply that I was trying to perform a Parse.Query.or function with a full object as apposed to a pointer to an object. Annoying that parse didn't give me a proper error, but in this case there is no bug.