Hi! I’m having trouble using existing Terraform modules in a step function using the new AwsTerraformAdapter in CDK. We have some existing Lambdas (imported from HCL modules) and would like to pass in their ARNs to the state machine defined in Terraform CDK, but the AWS library complains that the Terraform CDK token doesn’t look like an ARN.
To give some additional context, our process is to run cdktf synth
and then include the JSON output within our parent Terraform module, e.g.
# main.tf
module "cdksfn" {
source = "./cdk.out"
lambda-arn = module.my_lambda.lambda.arn
}
# cdk/main.ts
class MyStack extends TerraformStack {
myLambdaArn = new TerraformVariable(this, 'lambda-arn', { type: "string" });
constructor(scope: Construct, name: string) {
super(scope, name);
new AwsProvider(this, "aws", { region: 'us-west-2' });
const awsAdapter = new AwsTerraformAdapter(this, "adapter");
new stepfunctions.StateMachine(awsAdapter, "sfn", {
definition: new aws_stepfunctions_tasks.LambdaInvoke(awsAdapter, "my-lambda-step", {
lambdaFunction: lambda.Function.fromFunctionArn(
awsAdapter,
"my-lambda-id",
// Apparently the Terraform variable below can't be used as the ARN
// because it represents a TF token
this.myLambdaArn.stringValue),
}).next(new stepfunctions.Succeed(awsAdapter, "success"))
})
}
}
The above stack fails to synthesize with
ARNs must start with "arn:" and have at least 6 components: ${TfToken[TOKEN.1]}
Is it possible to use a Terraform variable within a step function definition defined in CDK (using the AwsTerraformAdapter)?