Heya again! I have a question regarding using exis...
# general
s
Heya again! I have a question regarding using existing resource parameters as inputs when creating new resources. I went through the "Input and Outputs" page on the documentation but I still can't seem to get it to work. For example - When I try to create a
aws.cloudwatch.MetricAlarm
and I want to use
<http://aws.lb|aws.lb>.TargetGroup.name
to construct the
resource_name
I get this error. source:
Copy code
aws.cloudwatch.MetricAlarm(
            resource_name=Output.concat("", target_group.name, "-CPUHigh-alarm"),
error:
Copy code
raise TypeError("Expected resource name to be a string")
    TypeError: Expected resource name to be a string
    error: an unhandled error occurred: Program exited with non-zero exit code: 1
Surprisingly, this same approach works for
aws.cloudwatch.MetricAlarm.dimensions
Copy code
treat_missing_data="breaching",
            dimensions={
                "TargetGroup": Output.concat("", args.target_group.name),
            },
I haven't been able to figure out how to use existing resource fields when creating new resources. What am I missing?
m
I can't speak to the Python SDK in particular, but in the one case, it sounds like Outputs are accepted as Inputs, but the other the Output needs to be applied.
a
The resource name is internal to Pulumi and must always be a plain string.
s
Is there a way to construct
resource_name
from an existing
Resource
object? Seeing that
resource_name
is a
required
property for creating new resources, how do you suggest we set this value dynamically?