awsdocs / aws-doc-sdk-examples

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not able to create and run a new Instance

rrajj opened this issue · comments

Expected behavior

Create a new instance and run a provided script.

Actual behavior

Nothing happens at the following line of code:

try {
    console.log(in try block);
    const response = await client.send(command);
    console.log(response);
  } catch (err) {
    console.error(err);
  }

Code just stops after printing in try block. Checked the console, no errors there.

Steps to reproduce

// Create a new EC2 instance.
export const main = async () => {
  const command = new RunInstancesCommand({
    ImageId: 'ami-07caf09b362be10b8',
    InstanceType: 't2.micro',
    // Ensure only 1 instance launches.
    MinCount: 1,
    MaxCount: 1,
  });

  try {
    const response = await client.send(command);
    console.log(response);
  } catch (err) {
    console.error(err);
  }
};```

2) Running the code should create and run an instance, BUT nothing happens at all.

Logs / stacktrace (if applicable)

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

Which SDK were you using?

JavaScript (v3)

Which OS were you using?

Linux

SDK version

No response

OS version

Ubuntu 22

Also I have Administrator Access.

Hey @rrajj, is this in relation to a specific code example or a more general JS SDK question? If it's related to the SDK, you would need to go to https://github.com/aws/aws-sdk-js-v3

@cpyle0819 thanks. I will check that out