Hey, I would like to use Pulumi for managing alrea...
# general
b
Hey, I would like to use Pulumi for managing already existing resources, created by other means. A simple example would be some AWS CloudWatch log groups, which come and go and I would like to modify their settings with Pulumi. Is this even possible? What I'm trying to achieve is something like this:
Copy code
import 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?