bland-book-36110
09/28/2023, 8:59 AM(...)
pipeline = aws.imagebuilder.ImagePipeline(
"ImagePipeline",
image_recipe_arn=recipe.arn,
infrastructure_configuration_arn=infrastructure_configuration.arn,
)
pulumi.export("Pipeline ARN", pipeline.arn)
def run_pipeline(pipeline_arn):
<http://pulumi.info|pulumi.info>(pipeline_arn)
runner = ec2.Instance(
"AmiInstance",
ami=ami_id,
instance_type=instance_type,
key_name=key_name,
iam_instance_profile=instance_profile.name,
user_data=runner_user_data_script,
)
pulumi.export("Public IP", runner.public_ip)
# This should only run if pipeline has been created/changed in this execution.
# Avoid running this code if pipeline has not been changed.
pipeline.arn.apply(lambda arn: run_pipeline(arn))
At this moment, when I do a pulumi up
, the run_pipeline
function is executed even before I select if I want to "perform the update" (the question that pulumi asks). Does anyone know which is the best way to do this?class MyAMI(pulumi.ComponentResource):
def __init__(self, name, opts=None):
super().__init__(
"pkg:example:AMI", name, props={}, opts=opts,
)
child_opts = pulumi.ResourceOptions(parent=self)
with open("/tmp/pulumi.log", "a") as file:
file.write("Running pipeline")
with open
statementstraight-cartoon-24485
09/28/2023, 11:02 PMpulumi up
I find that it helps to think of how pulumi programs work as "yaml", if you can't do it in yaml, you can't do it pulumi, generally speakingbland-book-36110
09/29/2023, 12:33 PM