Reputation: 61
System, packages and versions:
const iotTopicRule1 = new iotTopicRule.IotTopicRule(this, 'iot-topic-rule-1', {
...,
errorAction: {
s3: {
"roleArn": "arn:aws:iam::XXXXXXXXXXXXXXXXX:role/service-role/iot-write-to-failed-iot-s3-bucket",
"bucketName" : "failed-iot-action-messages",
"key" : "${replace(topic(), '/', '-') + '-' + timestamp() + '-' + newuuid()}",
}
}
})
When I run cdktf synth
all things works correctly, but, when I run cdktf deploy <stack-name>
the following error occur:
There is no function named "newuuid"
It's like terraform tries to run newuuid instead of sending that to AWS.
I expect the topic to be created in AWS as defined via typescript.
Upvotes: 2
Views: 28
Reputation: 61
After trying several ways, I found the solution. The string defined in TypeScript must be escaped, otherwise Terraform sees the dollar sign as something to be executed locally.
So now it looks like this:
const iotTopicRule1 = new iotTopicRule.IotTopicRule(this, 'iot-topic-rule-1', {
...,
errorAction: {
s3: {
"roleArn": "arn:aws:iam::XXXXXXXXXXXXXXXXX:role/service-role/iot-write-to-failed-iot-s3-bucket",
"bucketName" : "failed-iot-action-messages",
"key" : "$${replace(topic(), '/', '-') + '-' + timestamp() + '-' + newuuid()}",
}
}
})
Now it's works correctly.
Upvotes: 1