Hi Friends, how can i modify pulumi output value ?...
# cloudengineering-support
e
Hi Friends, how can i modify pulumi output value ? my example: when I create an ec2 instance I want to take the instance private IP: '10.1.101.21' and create a reverse record(ptr) usually, I would do the following
Copy code
app_instance = ec2.Instance(........)
ip=app_instance.private_ip
ptr_splitted = ipaddress.ip_address(ip).reverse_pointer.split('.')
ptr_splitted[0] + '.' + ptr_splitted[1]
the output I'm expecting is:
21.101
my problem is when I send this function the ec2 instance IP it send the
pulumi.output.Output
object I'm familiar with the
Output.concat
function but in my case, I need to change the actual string and I didn't find any examples on how to do that. I would appreciate your suggestions.
@here
any suggestions?
w
You need to use
.apply()
(https://www.pulumi.com/docs/intro/concepts/programming-model/#apply) Here is a simple example that hopefully helps:
Copy code
# Create an AWS resource (S3 Bucket)
bucket = s3.Bucket('my-bucket')
bucket_name_array = bucket.id.apply(
    lambda id: id.split("-")
)
pulumi.export('bucket_name', bucket.id)
pulumi.export('name_array', bucket_name_array)
1