Data source in CDKTF

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.

I changed ami: ... to ami: Fn.element(amis.ids, 0) which resolved the AMI issue. However, I am experiencing a similar issue when creating the private key and writing to a local file, not sure how to do this in CDKTF, in HCL I just specify the content in a local_sensitive_file block. How do I do this in CDKTF?