https://pulumi.com logo
Title
a

average-school-38756

08/27/2021, 11:16 PM
how can i use the name of a resource i'm defining in one of its properties? for example, if i create a Firehose stream with logging in the console, AWS uses the name of the stream in the log group name. but how can i do that in Pulumi?
stream = aws.kinesis.FirehoseDeliveryStream(
    'my-stream",
    destination="s3",
    s3_configuration=aws.kinesis.FirehoseDeliveryStreamS3ConfigurationArgs(
        role_arn=my_role.arn, 
        bucket_arn=data_lake.arn, 
        cloudwatch_logging_options=aws.kinesis.FirehoseDeliveryStreamS3ConfigurationCloudwatchLoggingOptionsArgs(
            enabled=True,
            log_group_name=f'aws/kinesisfirehose/{stream.name}',  # FIXME: undefined at this point
            log_stream_name='S3Delivery'
        )
    ),
)
l

little-cartoon-10569

08/29/2021, 9:26 PM
You want to use "my-stream" in place of stream.name? Can you not do that already?
log_group_name=f'aws/kinesisfirehose/my-stream
a

average-school-38756

08/30/2021, 12:11 AM
no, i want to use "my-stream-<rand-hash>"
l

little-cartoon-10569

08/30/2021, 1:08 AM
The name isn't known at creation time. To achieve this, you would have to set the name yourself. There is a configuration arg "name" that you can pass into the stream constructor.
g

great-sunset-355

08/30/2021, 8:03 AM
Note there is a difference between
resource_name
and the physical
name
of the resource that gets deployed. By default, Pulumi is trying to help you by generating a physical name from the
resource name
if possible. And also uses
resource_name
as a reference inside the
state
file. As tenwit suggested you can override generated name with passing in your own name via
name=
argument.
a

average-school-38756

08/30/2021, 3:34 PM
thanks