Hello,
I am trying to build reusable modules using terrafrom cdktf and each of them is a separate project (which means that each module needs terrafrom cdktf init to create it) .
So in order to achieve this i tried to build the module using npm run compile and then i included it in my package.json in my implementation .
But the wired thing is when i use DataSources or TerraformAssets in my modules i get unexpected error which :
Error: No stack could be identified for the construct at path 'powershell_script'
This is my module :
export class LinuxBaseLineNodeModule extends Construct {
public props: BaseLineNodeProps;
constructor(scope: Construct, id: string, props: BaseLineNodeProps) {
super(scope, id);
this.props = props;
let generic_tags = {
environment: props.environment,
product: props.product,
};
new AwsProvider(scope, "aws");
const ami = new DataAwsAmi(this, 'ami', {
mostRecent: true,
owners: ['amazon'],
filter: [
{
name: 'name',
values: [`amzn2-ami-hvm-*-x86_64-gp2`],
},
],
});
const powershell = new TerraformAsset(scope, "powershell_script", {
path: "./scripts/user-data.ps1",
type: AssetType.FILE,
});
// Resources
new Instance(scope, "instance", {
ebsOptimized: true,
ami: ami.arn,
instanceType: "t2.micro",
userData: Token.asString(
Fn.file(powershell.path),
),
tags: generic_tags,
});
}
}