Seeking assistance with TypeScript promises

Just starting out with typescript and nodejs, but I've got to tackle some issues in the typescript code.

I'm looking to execute an ECS one-off task using Pulumi. I have the documentation on how to run the task from the taskDefinition, which can be found here.

However, without a detailed explanation, I'm struggling to understand how to invoke the `run` action mentioned here:

public run: (params: RunTaskRequest) => Promise<awssdk.ECS.Types.RunTaskResponse>;

There's an example provided for running this with api-gateway, but it doesn't clarify how to call the `run` function as a stand-alone action. You can check it out here.

Any advice or assistance would be greatly appreciated!

UPD: Here is the more detailed block of code that I'm working with:

const kafkaTask = new awsx.ecs.FargateTaskDefinition("kafka1-task-efs", {
    vpc: vpcSelected,
    containers: {
        kafkaTask: {
            image: imageKafkaTaskEfs,
            logConfiguration: {
                logDriver: "awslogs",
                options: {
                    "awslogs-group": "ecs-kafka1",
                    "awslogs-region": "eu-central-1",
                    "awslogs-stream-prefix": "kafka1-task-efs"
                }
            },
            mountPoints: [
                {containerPath: "/mnt/kafka/data", sourceVolume: "kafka-data"},
                {containerPath: "/mnt/kafka/secrets", sourceVolume: "kafka-secrets"},
                {containerPath: "/mnt/zookeeper/log", sourceVolume: "zookeeper-log"},
                {containerPath: "/mnt/zookeeper/data", sourceVolume: "zookeeper-data"}
            ]
        }
    },
    volumes: [
        {name: "kafka-data", efsVolumeConfiguration: {rootDirectory: "/kafka-data", fileSystemId: fsKafka.id}},
        {
            name: "kafka-secrets",
            efsVolumeConfiguration: {rootDirectory: "/kafka-secrets", fileSystemId: fsKafka.id}
        },
        {
            name: "zookeeper-log",
            efsVolumeConfiguration: {rootDirectory: "/zookeeper-log", fileSystemId: fsKafka.id}
        },
        {
            name: "zookeeper-data",
            efsVolumeConfiguration: {rootDirectory: "/zookeeper-data", fileSystemId: fsKafka.id}
        }
    ]
});

kafkaTask.run({ cluster }).then(res => console.log(res)); 

UPD2: I encountered the following error, not sure if it provides any helpful insights:

error: Running program '/pulumi/main-infrastructure' failed with an unhandled exception:
Error: Cannot call '.get' during update or preview.
To manipulate the value of this Output, use '.apply' instead.
    at Proxy.get (/pulumi/node_modules/@pulumi/pulumi/output.js:172:15)
    at FargateTaskDefinition.run (/pulumi/node_modules/@pulumi/ecs/taskDefinition.ts:226:39)
    at /pulumi/main-infrastructure/index.ts:127:15
    at Generator.next (<anonymous>)
    at fulfilled (/pulumi/main-infrastructure/index.ts:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
error: update failed

Answer №1

If you're struggling with where the issue lies, it seems like you need to instantiate an object of type EC2TaskDefinition. Here's a basic framework to get you started:

const taskDef = new EC2TaskDefinition('', {}, {})

taskDef.execute({})
.then(response => console.log(response))

It looks like there are some parameters that need to be filled in, and if creating an instance is the problem, please let me know so I can provide more guidance on that aspect.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Despite being listed in the entry components, HelloComponent is not actually included in the NgModule

Check out my StackBlitz demo where I am experimenting with dynamically instantiating the HelloComponent using the ReflexiveInjector. The HelloComponent is added to the app modules entryComponents array. Despite this setup, I am still encountering the foll ...

Guide to dynamically setting the index element with ngFor in Angular

When working with NgFor in Angular, I am interested in dynamically handling attributes using an index. I have a collection of properties/interfaces that look like this: vehicle1_Name, vehicle2_Name, vehicle3_Name vehicle4_Name, totalVehCount To achieve t ...

Having trouble with Angular 5 tsconfig baseURL not functioning properly?

This may appear straightforward, but I am facing difficulties with it My Angular 5 application consists of three files located as follows: app_directory/tsconfig.json app_directory/src/app/services/my-service.service.ts app_directory/src/app/main/sub1/su ...

Problem with Typescript: The type '{ x;y }' is required to have a '[Symbol.iterator]()' method

Just starting out with Typescript and tackling the task of converting a React project from JavaScript to TypeScript. I've been diving into various posts for guidance, but I feel like I'm going in circles. Any assistance would be greatly appreci ...

Trigger on the cancellation or completion of a nested observable

I'm seeking a way to detect if an inner observable was not successfully completed (due to everyone unsubscribing) and then emit a value in that scenario. Something akin to defaultIfEmpty, but the current solution isn't effective. A trigger exis ...

What could be causing my TypeScript code to not be recognized as CommonJS?

I rely on a dependency that is transpiled to ES6. My goal is to leverage ES2019 features in my own code. Ultimately, I aim to output ES6. This is how I set up my tsconfig { "compilerOptions": { "module": "CommonJS" ...

Allowing cross-origin resource sharing (CORS) in .NET Core Web API and Angular 6

Currently, I am facing an issue with my HTTP POST request from Angular 6. The request is successfully hitting the .net core Web API endpoint, but unfortunately, I am not receiving the expected response back in Angular 6. To make matters worse, when checkin ...

Differences between ts-loader and babel-loader when working with TypeScript in webpack

Recently, I set out to compare the compiled output code between these two configurations. ts-loader { test: /\.tsx?$/, use: 'ts-loader', } babel-loader use: { loader: 'babel-loader', options: { p ...

What is the best way to search for and isolate an array object within an array of objects using Javascript?

I am attempting to narrow down the list based on offerings const questions = [ { "id": 2616, "offerings": [{"code": "AA"},{"code": "AB"}]}, { "id": 1505, "offerings": [ ...

Create a constant object interface definition

Is there a way to create an interface for an object defined with the as const syntax? The Events type does not work as intended and causes issues with enforcement. const events = { // how can I define an interface for the events object? test: payload ...

The Angular library files built with ng build are not automatically included in the dist folder

My Angular 9 library has a project structure similar to the one shown below https://i.sstatic.net/gznfr.png After running ng build falcon-core to build the library, I noticed that the view-model files are missing from the dist folder https://i.sstatic.n ...

Dividing a TypeScript NPM package into separate files while keeping internal components secure

I have developed an NPM package using TypeScript specifically for Node.js applications. The challenge I am facing is that my classes contain internal methods that should not be accessible outside of the package, yet I can't mark them as private since ...

Best practices for asynchronous REST PATCH operations

I am dealing with a REST API that accepts a patch request containing various parameters such as firstname, lastname, image, and birthday. The challenge arises when determining how to handle the upload of an image parameter to a Content Delivery Network (CD ...

Exploring NestJS: Leveraging the @Body() Decorator to Retrieve Request Body Data

import { Controller, Post, Body } from '@nestjs/common'; import { MyService } from 'my.service'; import { MyDto } from './dto/my.dto'; @Controller('my-route') export class MyController { constructor(private rea ...

gulp-tsc cannot locate the src directory

I am currently working on developing a .NET Core application using Angular2, but I keep encountering the following error: /wwwroot/NodeLib/gulp-tsc/src/compiler.ts' not found. I'm having trouble pinpointing what I might be missing. tsconfig.js ...

Experiencing a hitch when attempting to deploy an Angular 2 application on Heroku

Encountering the sh: 1: tsc: not found Error when attempting to deploy an Angular 2 app on Heroku. Using Node version: v7.2.0 and npm Version: v4.0.3. View the error on Heroku Any suggestions on how to resolve this issue? ...

Modify the MUI time picker to display as a digital clock inside a DateTimePicker widget

I need to update my MUI DateTimePicker component to use the DigitalClock time picker instead of the Analog Clock picker. The current component has two steps, first picking the date from a calendar and then selecting the time. This change is only necessary ...

Is it no longer possible to instantiate an object using the syntax <interface>{}?

There seems to be an issue with the code snippet below when run in the TypeScript playground: interface Person { name: string; age: number; } const makePerson= function(name : string, age : number) : Person { let obj = <Person>{} ...

Can a "fragile export" be generated in TypeScript?

Testing modular code can be challenging when you have to export things just for the purpose of testing, which can clutter your code and diminish the effectiveness of features like "unused variable" flags on compilers or linters. Even if you remove a usage ...

Outputting double columns with Typescript Sequelize associations

I am currently in the process of constructing table models using sequelize along with typescript. Here is an example of one of my models: 'use strict'; import { Model, InferAttributes, InferCreationAttributes, CreationOptional } from 'seque ...