简体   繁体   中英

How to print the string value from cdktf data sources with python

Problem

I am trying to retrieve the su.net cidr block range using CDKTF data_aws_su.net, but doing so gives me an output as $TfTokenTOKEN instead of an actual cidr range (example 10.42.0.0/24)

Code

import cdktf_cdktf_provider_aws.data_aws_subnet as DataAwssubnet_

self.data_subnet = DataAwssubnet_.DataAwsSubnet(
            self.scope_obj,self.id_, availability_zone = '$$-south-1a', vpc_id='vpc-0d$$$e$$$$2$$$$3')

print(self.data_subnet.cidr_block)

above code outputs some weird encrypted value instead of a string

How can I print this value using data_aws_su.net module of CDKTF?

You are looking at aToken there, to print the cidr_block you need to use a TerraformOutput .

import cdktf_cdktf_provider_aws.data_aws_subnet as DataAwssubnet_
from cdktf import TerraformOutput

self.data_subnet = DataAwssubnet_.DataAwsSubnet(
        self.scope_obj,self.id_, availability_zone = '$$-south-1a', vpc_id='vpc-0d$$$e$$$$2$$$$3')

TerraformOutput(self, "subnet_cidr_block", value=self.data_subnet.cidr_block)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM