What is the process for including a component with the type IResolvable in a CfnImageRecipe CDK resource?

I encountered an issue with the CDK while attempting to create a CfnImageRecipe. The error message

error TS2322: Type 'string' is not assignable to type 'ComponentConfigurationProperty | IResolvable'
keeps popping up.

Below is the code snippet that triggered the error:

    const imageRecipe = new imagebuilder.CfnImageRecipe(this, 'MediaRecipe', {
      name: 'MediaRecipe',
      components: ["arn:aws:imagebuilder:us-west-1:aws:component/amazon-cloudwatch-agent-linux/1.0.0"],
      parentImage: 'centos:latest',
      version: '1.0.0',
      workingDirectory: '/tmp'
    });

It seems like the issue lies in using a string where it's not supposed to be used. Unfortunately, reliable documentation regarding this matter is hard to come by.

Answer №1

This solution has been effective for me (it appears to synthesize properly).

import * as cdk from '@aws-cdk/core';
import {CfnImageRecipe} from '@aws-cdk/aws-imagebuilder';

export class TemporaryStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new CfnImageRecipe(this, 'example-id', {
      name: 'MediaRecipe',
      components: [
        { 
          componentArn:"arn:aws:imagebuilder:us-west-1:aws:component/amazon-cloudwatch-agent-linux/1.0.0"
        }
      ],
      parentImage: 'centos:latest',
      version: '1.0.0',
      workingDirectory: '/tmp'
    });
  }
}

Which Integrated Development Environment are you using? Personally, I use WebStorm and with TypeScript much of this code is automatically suggested for you. It could potentially simplify your exploration process.

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

What causes TypeScript to struggle with inferring types in recursive functions?

Here is a code snippet for calculating the sum: //Function to calculate the sum of an array of numbers let sum = ([head, ...tail]: number[]) => head ? head + sum(tail) : 0 let result: string = sum([1, 2, 3]); alert(result); Can anyone explain why ...

Utilizing Typescript to define key-value pairs within a structured form

I've been creating a form structure that's functioning smoothly, but I've encountered an interesting issue with field validation in the validation part. While my Visual Code is pointing out that 'required2' in the phone constant n ...

Updating the background image on a modal in Angular2/Ionic2

Looking to change the background of a modal by clicking something on the homepage? I have a home page and a modal page with its own background. How can I dynamically alter the modal's background from the homepage? modal.html <ion-content> ...

What could be causing a Typescript-defined class property to unexpectedly appear as undefined?

My component has a property called options, which I have defined in the class. However, when I run the code in the browser, it's showing up as undefined. Despite thoroughly checking the code logic, I can't seem to pinpoint any issues. This could ...

The value of 'This' is not defined within the subscribe function

Need help debugging a subscribe statement where 'this' is always undefined inside it. Specifically, 'this.dataLoaded' is coming up as undefined. How can I ensure that it is defined during debugging? this.router.events .filt ...

Identifying memory leaks caused by rxjs in Angular applications

Is there a specific tool or technique available to identify observables and subscriptions that have been left behind or are still active? I recently encountered a significant memory leak caused by components not being unsubscribed properly. I came across ...

Can you please explain the distinction between the .ts and .tsx file extensions? They are both commonly used for TypeScript files in a React environment, but what is the specific use case for each

Hello, I'm in the process of learning React and as I work on my project, I've noticed files with both the .ts and .tsx extensions. I'm a bit confused about when to use .ts versus .tsx. Any guidance on this topic would be greatly appreciated. ...

Troubleshooting the issue of Angular 8 nested routes and multiple router outlet functionality not functioning as intended

I am currently working on an Angular 8.3 application, but I am facing issues with the routing functionality. When navigating to /logs, there are no errors displayed on the screen. However, accessing /logs/detailed/1036 results in a console error: "Error: ...

Determine the category of a container based on the enclosed function

The goal is to determine the type of a wrapper based on the wrapped function, meaning to infer the return type from the parameter type. I encountered difficulties trying to achieve this using infer: function wrap<T extends ((...args: any[]) => any) ...

Tips for preventing the occurrence of a "cycle dependency" error in the scenario where a service is requiring the importation of another service

In my Angular front-end project, I am working on consolidating all HTTP calls to the back-end within a single service. The commit causing issues can be found here (with just one change for it to work), and here is a summary of the changes. I have a class ...

Exploring React State Management: Leveraging the Context API as a centralized store for

Currently, I am developing a React web application using TypeScript. To enhance the State Management, I decided to implement React Hooks and Context API by following a concise tutorial that I came across here. Despite diligently following the tutorial, my ...

Display elements conditionally based on the result of an asynchronous operation within an ng

Using Angular version 11.0.2 I am encountering issues with the async pipe inside an ngIf template, where my data is not being properly refreshed. To illustrate this problem, I have created a simplified example. View code on Plunker To reproduce the issu ...

Creating a proper schema for an array of subdocuments in Mongoose within NestJS without relying on the default _id or redefining ObjectId

Currently, I'm delving into Nest.js and facing a challenge in creating a Schema with decorators that encompass an array of sub-document fields. I encounter no issues regarding importing/exporting the Schema or converting it to a model until: https:/ ...

An issue of "SignatureDoesNotMatch" arises while trying to send an email using Node AWS SDK for the Simple Email Service

I am facing an issue while attempting to send an email using the @aws-sdk/client-ses SDK in Node. The error I encounter is: SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access ...

Utilize your access token to send a message through Google Business Messages

Currently, I have successfully set up a method to send messages using the Google Business Messages API from an agent to a user through NodeJS. const bmApi = new businessmessages.businessmessages_v1.Businessmessages({}); This process requires authenticatio ...

Make sure that every component in create-react-app includes an import for react so that it can be properly

Currently, I am working on a TypeScript project based on create-react-app which serves as the foundation for a React component that I plan to release as a standalone package. However, when using this package externally, I need to ensure that import React ...

Troubleshooting: Unable to switch i18n language in TS/ReactJS

Recently, I integrated TypeScript into my project and encountered an issue with my i18n system. Previously, everything was working smoothly with the language toggle using "i18n.changeLanguage([language])". However, since transitioning to TypeScript, the to ...

What is the best way to implement lazy loading for child components in React's Next.js?

I am exploring the concept of lazy loading for children components in React Next JS. Below is a snippet from my layout.tsx file in Next JS: import {lazy, Suspense} from "react"; import "./globals.css"; import type { Metadata } from &quo ...

What is the most efficient way to set default props for a component?

According to the official documentation, the best practice for setting default props for a component is as follows: interface Props { /** * default value set to 100 */ size?: number } function Avatar({ size = 100 }: Props) { // ... } An ...

Function to convert a property with a default value to an optional generic type

I created a function to validate FormData objects with Zod, using a generic type for flexibility across schemas. Here's the validate function: export function validate<T>( formData: FormData, schema: z.ZodSchema<T> ): { validatedD ...