I'm trying to write a simple aws lambda js function that when I pass region, volumeid and volumetype it changes the volume type of the volume with that ID.
Anyway, whenever I try to test the function passing all the parameters, I get the function timing out after 3000ms, but I can't understand why...
Can somebody help me?
Many thanks in advance!
const AWS = require('aws-sdk');
const ec2 = new AWS.EC2({ region: event.instanceRegion });
ec2.ModifyVolume({ VolumeId: [event.volumeId] , VolumeType: [event.VolumeType] });
Related
I have a skill developed in Alexa which is linked with a lambda function in AWS.
In the lambda function when I start the session I have the following function:
/**
* Called when the session starts.
*/
function onSessionStarted(sessionStartedRequest, session)
{
console.log("Session starts");
console.log(`onSessionStarted requestId = ${sessionStartedRequest.requestId}, sessionId = ${session.sessionId}`);
}
Can sessionID be linked to the alexa account ID of who ran the skill?
As far as I know, the sessionId is a randomly generated ID and most probably Amazon will keep it linked to the skillId and the userId but that information is not made available to the developers.
I have a small Node.js function on AWS Lambda that returns a very simple dynamic response, such as:
exports.handler = async (event, context) => {
const response = {
statusCode: 200,
body: "Hello World " + Math.random(),
};
return response;
};
I want to deploy this on the public web through lambda#edge. To do this, I need to connect it to a CloudFront distribution. However, CloudFront requires that I choose an origin. This function doesn't need an origin.
Is it possible to deploy this without a CloudFront origin or do I need to create a dummy page, such as a static file on S3?
Don't create a dummy page. You can set an arbitrary domain name as the distribution origin.
If you use a function as a Viewer Request handler, you can set any domain name, for example dev.null.
If you use a function as an Origin Request handler, the domain name must be an existing valid name, for example example.com. As AWS support says, CloudFront performs a DNS validity check for the origin domain, but doesn't send requests to the domain (if the function returns a response).
When creating a custom labeling job for Amazon SageMaker Ground Truth Custom
Am getting the following error:
Cannot read property 'taskInput' of null
The pre-annotation AWS Lambda function should provide an object named taskInput and that object's properties can be accessed as {{ task.input. }} in your template.
https://docs.aws.amazon.com/sagemaker/latest/dg/sms-custom-templates-step2-demo1.html
so in your pre-annotation lambda function you need to make sure to forward the taskInput; e.g.:
exports.handler = async (event) => {
return {
"taskInput": event['dataObject']
}
};
I have a Cloud Code function that is being called by users. In that function, I create a new object, "Invitation", which triggers a before_save handler when saving.
Since a user is running the Cloud Code function, I would expect request.user in the before_save function to be the same, but it appears to be saving the Invitation object as master, resulting in request.user being null.
Parse.Cloud.define("sendInvite", function(request, response) {
var invitation = new Invitation();
invitation.save().then(function(invitation){
response.success();
}, function(error){
response.error(error);
});
});
Parse.Cloud.beforeSave("Invitation", function(request, response) {
var sender = request.user;
// sender is null, since master key is being used...
});
This doesn't seem like correct behaviour – the cloud code function shouldn't default to executing using the master key unless explicitly told to do so.
Any thoughts?
The issue was that Parse.Cloud.useMasterKey() was used outside of a function in one of our requires for Parse Hosting (require(cloud/app.js)).
The two cases when CloudCode uses the master key are when the CloudCode calls Parse.Cloud.useMasterKey() or when the CloudCode was invoked by a caller which uses the master key. Check whether sendInvites is being called from an environment which uses the master key.
I'm getting {"code":101,"error":"object not found for update"} when calling save on my role after adding a user to it, all on Cloud Code.
Sample code:
var role_query = new Parse.Query('_Role')
role_query.equalTo('name', 'USER')
role_query.first().then(function(role) {
role.getUsers().add(user)
role.save()
})
The error was that I didn't have permission to update the role.
Solution was using Parse.Cloud.useMasterKey() at the beginning of the Cloud Code function.
In case you need to update roles on the client:
https://www.parse.com/questions/role-cant-assign-user-in-js