typescript - 如何将 IResolvable 类型的组件添加到 CfnImageRecipe CDK 资源?
问题描述
我看到了这个错误:error TS2322: Type 'string' is not assignable to type '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'
});
显然它不会接受刺痛,我只是找不到任何像样的文档。
解决方案
这似乎对我有用(至少它合成)。
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'
});
}
}
你用的是什么IDE?我正在使用 WebStorm,在 Typescript 中,很多都是为您提示的代码。它可能会使探索变得更容易一些。
推荐阅读
- javascript - 如何将 html 文件包含在另一个 html 文件中,然后通过 javascript jquery 发出警报结果
- ruby - 将 UTC 时间转换为 PST 时间 Ruby
- neural-network - 神经网络,权重计算公式
- reactjs - 使用 redux 从表单组件向状态对象添加新属性
- java - 使用 Java AsyncHttpClient(AHC) 库进行同步调用 -
- node.js - docker run 让我进入一个节点 repl
- windows - Inkscape 从 Windows 命令行取消组合所有内容
- node.js - 从 GPG 公钥中提取电子邮件?
- javascript - chrome.tabs.executeScript 不是函数吗?
- python - 到前一行的行总和?