-
Notifications
You must be signed in to change notification settings - Fork 559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to create and run a new Instance #6091
Comments
Hi @rrajj - thanks for reaching out. I'm not able to reproduce it on my end with the code below and I would suggest modifying your code inside async function. const { EC2Client, RunInstancesCommand } = require("@aws-sdk/client-ec2");
// Set up AWS credentials and region
const AWS_REGION = "your-aws-region";
const AWS_ACCESS_KEY_ID = "your-access-key-id";
const AWS_SECRET_ACCESS_KEY = "your-secret-access-key";
// Set up EC2 client
const ec2Client = new EC2Client({
region: AWS_REGION,
credentials: {
accessKeyId: AWS_ACCESS_KEY_ID,
secretAccessKey: AWS_SECRET_ACCESS_KEY
}
});
// Set up parameters for the runInstances command
const params = {
ImageId: "your-ami-image-id",
InstanceType: "t2.micro",
MaxCount: 1,
MinCount: 1
// Add more parameters as needed
};
// Create a function to run the EC2 instance
const runEC2Instance = async () => {
try {
// Call the runInstances command
const data = await ec2Client.send(new RunInstancesCommand(params));
console.log("Instance ID:", data.Instances[0].InstanceId);
} catch (err) {
console.error("Error running EC2 instance:", err);
}
};
// Call the function to run the EC2 instance
runEC2Instance(); If it doesn't get resolved, please add this middewareStack which would output raw request and share so that I can further investigate.
Best, |
Hey @aBurmeseDev , I am using it as a Lambda function, just to make sure, for this task what should be an ideal timeout duration ? |
Below is the code I ran right now. Let me know if that looks any good. (new to this)
The console log prints:
|
@aBurmeseDev Hi, any further help? |
Solved |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Checkboxes for prior research
Describe the bug
Nothing happens at the following line of code:
Code just stops after printing in try block. Checked the console, no errors there.
SDK version number
2.1618.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.5.1
Reproduction Steps
Observed Behavior
Checked the AWS Console, for the particular deployment. It prints the line "in try block" and stops. Below is the log stack
2024-05-12T18:29:43.843Z 5f9b7776-03f7-4a6b-9e6a-246ea0ef1faa INFO in try block
END RequestId: 5f9b7776-03f7-4a6b-9e6a-246ea0ef1faa
REPORT RequestId: 5f9b7776-03f7-4a6b-9e6a-246ea0ef1faa Duration: 597.59 ms Billed Duration: 598 ms Memory Size: 128 MB Max Memory Used: 128 MB Init Duration: 647.20 ms
Expected Behavior
Create a new instance and run a provided script.
Possible Solution
No response
Additional Information/Context
I have Administrator Access.
The text was updated successfully, but these errors were encountered: