我想创建流水线传送流并从CloudFormation参数读取缓冲提示和AssetImage
标志。
我发现了在有人需要字符串(例如队列名)的情况下该怎么做
enabled
我不知道该如何做数字或布尔值。在以下代码中,我应该对XXXXXXXXXXXXXX和YYYYYYYYYYYYYYY使用什么?
new sqs.Queue(this, 'MyQueue', {
queueName: Fn.conditionIf('Condition', 'Hello', 'World').toString()
});
答案 0 :(得分:0)
我找到了YYYYYYYYYYYYYYYYY应该使用什么。
这是怎么回事?事实证明,某些值的类型不必是标量(string
,number
,...),而可以是IResolvable
,它允许CDK在综合期间对其求值。例如,这是DataFormatConversionConfigurationProperty
中node_modules/@aws-cdk/aws-kinesisfirehose/lib/kinesisfirehose.generated.d.ts
的声明:
export declare namespace CfnDeliveryStream {
interface DataFormatConversionConfigurationProperty {
readonly enabled: boolean | cdk.IResolvable;
readonly inputFormatConfiguration: CfnDeliveryStream.InputFormatConfigurationProperty | cdk.IResolvable;
readonly outputFormatConfiguration: CfnDeliveryStream.OutputFormatConfigurationProperty | cdk.IResolvable;
readonly schemaConfiguration: CfnDeliveryStream.SchemaConfigurationProperty | cdk.IResolvable;
}
}
这意味着我们可以对enabled
属性使用以下内容
const cfnParam = new CfnParameter(this, "EnableFirehoseDataFormatConversion", {
type: "String"
});
const cfnCondition = new CfnCondition(this, "FirehoseDataFormatConversionEnabled", {
expression: Fn.conditionEquals(cfnParam.valueAsString, "true"),
});
const enabledOrNot: IResolvable = Fn.conditionIf(cfnCondition.logicalId, true, false);
new kinesisf.CfnDeliveryStream(this, "MyFirehose", {
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-kinesisfirehose-deliverystream-extendeds3destinationconfiguration.html
extendedS3DestinationConfiguration: {
bucketArn: dataBucket.bucketArn,
bufferingHints: {
intervalInSeconds: XXXXXXXXXXXXXX,
sizeInMBs: 128,
},
compressionFormat: "UNCOMPRESSED",
dataFormatConversionConfiguration: {
enabled: enabledOrNot
},
roleArn: myRole.roleArn,
prefix: dataStoragePrefixInS3,
errorOutputPrefix: errorStoragePrefixInS3,
}
});
此方法不适用于XXXXXXXXXXXXXX,因为intervalInSeconds
的类型是number
而不是number | IResolvable
。但是,bufferingHints
的类型为IResolvable
,因此您应该能够指定整个结构。我还不知道如何构建将返回结构的IResolvable
实例。