alert-raincoat-81485
06/14/2021, 7:44 PMimport pulumi
import pulumi_aws as aws
asg_name = {}
class ASG():
def __init__(self):
self.name = name
# Creating Autoscaling.
asg_name[name] = aws.autoscaling.Group(.....defs....)
inst1 = ASG(idx1)
inst2 = ASG(idx2)
inst3 = ASG(idx3)
defineASG(a,inst_type)
## Boto API create EC2 tags ##
asg_id = {}
asg_id['idx1'] = autoScale['idx1'].name.apply(
lambda a: defineASG(asg=a, inst_type='idx1')
asg_id['idx2'] = autoScale['idx2'].name.apply(
lambda a: defineASG(asg=a, inst_type='idx2')
asg_id['idx3'] = autoScale['idx3'].name.apply(
lambda a: defineASG(asg=a, inst_type='idx3')
little-cartoon-10569
06/14/2021, 9:03 PMapply()
on name? What are you doing with the name; is it being passed into a constructor of a Pulumi resource? You don't need to call apply()
in this case.alert-raincoat-81485
06/14/2021, 9:07 PMapply()
here for some specific reason.
When the Autoscaling class will create multiple instance of asg groups eg idx1. iidx2...n
on each instance, apply()
will be called on each instance class and start creating EC2 tags for example for ’idx1" instance class, it will create tags as idx1-1, idx1-2, idx1-3..n
.little-cartoon-10569
06/14/2021, 9:14 PMapply()
(or interpolate()
) is performed on parameters to the constructor. If it's possible, then this will at least eliminate a potential source of issues. Here's an example from the Pulumi examples repo: https://github.com/pulumi/examples/blob/71a705e12b1ea6b132ecf164f0a71adabc78b4ce/aws-py-apigateway-lambda-serverless/__main__.py#L78aws.lambda_.Permission()
could have happened inside the apply()
for the same effect, but doing it this way allows Pulumi to better report on dependencies. And it may avoid the issue you're seeing.alert-raincoat-81485
06/15/2021, 5:28 PMapply()
, but in a loop it picks the last element and execute apply()
rather it has to go through each element and call apply()
little-cartoon-10569
06/15/2021, 9:30 PMapply()
or not. I'm not familiar with Python's scoping rules, they may be throwing a spanner in the works here.
Maybe the question could be asked in #python, along with the looping code that isn't working for you?