sparse-state-34229
04/12/2020, 7:37 AMstr(vpc.cidr_block[0]['resourceRecordValue'])
nor str(vpc.cidr_block[0].resource_record_value)
workresource_record_value
is a route53 thing. if so, it would be helpful to use more general examplesbig-piano-35669
apply
function is generally what you want here:
def dothing(vpc):
vpc.cidr_block.apply(do_thing)
sparse-state-34229
04/12/2020, 6:51 PMOutput
vpc_network = ip_network('10.0.0.0/8')
it works finefaint-table-42725
04/13/2020, 5:36 AMapply
will return an Output
Output
as a promise or async taskvpc_network
is still an Output
— if you want to print it, L3 should be vpc_network.network_address.apply(print)
— you’re able to reference network_address
through lifting; the more literal way to write this would be vpc_network.apply(lambda v: print(v.network_address))
sparse-state-34229
04/15/2020, 7:19 AMvpc_name = Output.all(tags).apply(lambda x: x[0].get('Name'))
then vpc_name
is still an Output, but according to the docs that is lifting?vpc_name
later in a formatted string it doesn’t workawsec2SecurityGroup (<pulumi.output.Output object at 0x10ed737c0>-bastion-ingress):
error: Error creating Security Group: InvalidParameterValue: Invalid security group name. Valid names are non-empty strings less than 256 characters from the following set: a-zA-Z0-9. _-:/()#,@[]+=&;{}!$*
status code: 400, request id: 210d586d-f079-45cd-9450-637c32c0f324
vpc_name = Output.all(tags).apply(lambda x: x[0].get('Name')) # tags are a pulumi_aws.ec2.Vpc object tags
name = f'{vpc_name}-bastion-ingress'
bastion_ingress = ec2.SecurityGroup(name,
name=name,
name
it is an outputec2.SecurityGroup