sparse-state-34229
03/26/2020, 3:46 AMfaint-table-42725
03/26/2020, 4:05 AMbucket.apply(print)
sparse-state-34229
03/26/2020, 4:08 AMf'{bucket.apply(str)}-bucket'
didn’t workgentle-diamond-70147
03/26/2020, 4:10 AMbucket.apply(lambda b: print(f'{b}-bucket'))
.apply()
..apply()
ing it as long as you don't need to manipulate or transform the value.sparse-state-34229
03/26/2020, 4:18 AMbucket.apply(print)
doesn’t send anything to diagnostics like a normal print()
does - should it?faint-table-42725
03/26/2020, 5:40 AMOutput.concat
in Python: https://www.pulumi.com/docs/intro/concepts/programming-model/#outputs-and-stringsOutput[str]
and not a strsparse-state-34229
04/12/2020, 7:31 AMvpc.cidr_block
to something that is not a Pulumi resource. so if the CIDR block is 10.0.0.0/16
then I want to pass that stringIndexError
?vpc_network = ip_network(vpc.cidr_block[0][1][500][6])
File "/Users/scott/.pyenv/versions/3.8.2/lib/python3.8/ipaddress.py", line 83, in ip_network
raise ValueError('%r does not appear to be an IPv4 or IPv6 network' %
ValueError: <pulumi.output.Output object at 0x108333af0> does not appear to be an IPv4 or IPv6 network
error: an unhandled error occurred: Program exited with non-zero exit code: 1
str(vpc.tags.apply(lambda x: f'{x.get("Name")}-{subnet_config.get("name")}_{availability_zone}'))
this does not return a string+ └─ awsec2Subnet <pulumi.output.Output object at 0x10c0c7be0> create
util-private_us-west-1b
faint-table-42725
04/13/2020, 5:31 AMapply
returns an Output
Output
valuestr
within the apply
but you’ll never get back a str
from the apply
itselfdo_thing
wants to take a str
— you should be doing something like vpc.cidr_block.apply(lambda cidr: do_thing(cidr))
Output[T]
where T
is the return type of do_thing
sparse-state-34229
04/20/2020, 3:09 AMvpc.id.apply(lambda x: x)
to EC2 user data which writes the value to a file, but the object repr is getting writtenreturn template.render(
kops_name=kops_name,
kops_state_store=f"s3://{kops_name}",
vpc_cidr=self.vpc_cidr,
vpc_id=self.vpc_id.apply(lambda f: f),
vpc_name=self.vpc_name,
)
cat > /etc/profile.d/envs.sh <<EOF
export KOPS_NAME="{{ kops_name }}" \
KOPS_STATE_STORE="{{ kops_state_store }}" \
VPC_CIDR="{{ vpc_cidr }}" \
VPC_ID="{{ vpc_id }}" \
VPC_NAME="{{ vpc_name }}"
EOF
root@ip-10-2-0-17:/etc/profile.d# cat envs.sh
export KOPS_NAME="foo.k8s.local" KOPS_STATE_STORE="s3://<bucket>" VPC_CIDR="10.2.0.0/20" VPC_ID="<pulumi.output.Output object at 0x10f621e80>" VPC_NAME="foo"
faint-table-42725
04/20/2020, 3:55 AMsparse-state-34229
04/20/2020, 3:59 AMOutput.all([x,y]).apply(fn: template.render(whatever))
faint-table-42725
04/20/2020, 4:00 AMOutput
which you can then pass to the constructor of a resourcesparse-state-34229
04/20/2020, 4:08 AM