Hi, I am trying to replicate one of my simple stacks from HCL to TypeScript (using CDKTF), I am having issues setting up a data source to get a list of AMIs. This is what I am trying to do:
const amis = new ec2.DataAwsAmiIds(this, "ami-ids", {
owners: ["amazon"],
nameRegex: "^amzn2-ami-hvm-*-x86_64-ebs",
filter: [{
name: "name",
values: ["amzn2-ami-hvm-*-x86_64-ebs"]
}]
});
I then try to reference this like so:
const instance = new ec2.Instance(this, "instance", {
instanceType: "t2.micro",
ami: `${amis.id}`,
...
The issue I am having is that this value will be a Token (${TfToken[TOKEN.1]}
), how to I get the string value from this in order to be able to pass it in? Thanks.
The same thing applies to generating a key pair using the TLS provider, here is the complete source code.