billowy-umbrella-55191
10/14/2024, 2:08 PMimport pulumi_aws as aws
import pulumi
loggroups = aws.cloudwatch.get_log_groups(
log_group_name_prefix="/test",
opts=pulumi.InvokeOptions(provider=provider),
)
for group in loggroups.log_group_names:
lg = aws.cloudwatch.get_log_group(name=group, opts=pulumi.InvokeOptions(provider=provider))
lg_opts = dict(
name=group,
kms_key_id=lg.kms_key_id,
log_group_class=lg.log_group_class,
retention_in_days=lg.retention_in_days,
opts=pulumi.ResourceOptions(provider=provider, import_=group, ignore_changes=["tags", "tagsAll"]),
)
if already_imported():
lg_opts |= dict(retention_in_days=14, opts=pulumi.ResourceOptions(provider=provider))
aws.cloudwatch.LogGroup(group, **lg_opts)
That is to automatically import the actual list of matching resources (here: log groups), then after they are already imported, modify some of their settings.
What's missing is the already_imported()
method, I couldn't find anything which could be used to determine if a resource is already in the Pulumi state or not.
I've used the automation API, where I can get and export the stack and find resources there, but I would like to use this feature in the "normal" python SDK. Any ideas?No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by