Typescript 如何将类型为IResolvable的组件添加到CfnImageRecipe CDK资源?

Typescript 如何将类型为IResolvable的组件添加到CfnImageRecipe CDK资源?,typescript,amazon-web-services,aws-cdk,Typescript,Amazon Web Services,Aws Cdk,我看到此错误:错误TS2322:类型“string”不可分配给类型“ComponentConfigurationProperty | IResolvable” 当我试图用CDK创建一个CfnImageRecipe时 代码如下: const imageRecipe = new imagebuilder.CfnImageRecipe(this, 'MediaRecipe', { name: 'MediaRecipe', components: ["arn:a

我看到此错误:
错误TS2322:类型“string”不可分配给类型“ComponentConfigurationProperty | IResolvable”
当我试图用CDK创建一个CfnImageRecipe时

代码如下:

    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'
    });
显然,它不会接受刺痛,我只是找不到任何关于这方面的体面的文档。

这似乎对我有用(至少是Synth)


你用的是什么IDE?我正在使用WebStorm,在Typescript中,很多代码都是提示给您的。这可能会使探索变得更容易。

我正在使用VScode-但您的解决方案奏效了,谢谢。不过,我看到了:
提供的父映像必须是EC2 AMI Id或有效的映像生成器映像Arn。
但在控制台中,它提供了从dockerhub提取的选项,因此我希望能够从dockerhub提取基本映像,然后在ecr中使用我们的自定义设置对该图像进行版本设置
import * as cdk from '@aws-cdk/core';
import {CfnImageRecipe} from '@aws-cdk/aws-imagebuilder';

export class TmpStack 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'
    });
  }
}