hello everyone, I'm new around here but am looking...
# typescript
hello everyone, I'm new around here but am looking forward to becoming an active contributor. I'm having a hell of a time getting an interpolated
to play nice with the
attribute. I've tried quite a few different approaches but I always seem to wind up with this in my aws console:
Copy code
Calling [toString] on an [Output<T>] is not supported.

To get the value of an Output<T> as an Output<string> consider either:
1: o.apply(v => `prefix${v}suffix`)
2: pulumi.interpolate `prefix${v}suffix`

See <https://pulumi.io/help/outputs> for more details.
This function may throw in a future version of @pulumi/pulumi.
The userData script is a fairly large bash script that is created by interpolating numerous outputs from other resources. When I export it it's correct in the Pulumi console. Full component code to follow in the thread ->
Copy code
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

const config = new pulumi.Config();

export interface WorkerLaunchTemplateArgs {
    stack: pulumi.Input<string>;
    instanceType: string;
    vpcSecurityGroupIds: pulumi.Output<any>[];
    userData: pulumi.Output<string>;
    ami: pulumi.Input<string>;

export default class WorkerLaunchTemplate extends pulumi.ComponentResource {


    constructor(name: string, args: WorkerLaunchTemplateArgs, opts?: pulumi.ResourceOptions) {

        super("pkg:index:WorkerLaunchTemplate", name, {}, opts);

        const launchTemplate = new aws.ec2.LaunchTemplate(`${args.stack}-${name}`, {
            imageId: args.ami,
            instanceType: args.instanceType,
            userData: Buffer.from(`${args.userData}`, 'utf8').toString('base64'),
            vpcSecurityGroupIds: args.vpcSecurityGroupIds,
            tagSpecifications: [{
                resourceType: "instance",
                tags: {
                    Name: `${args.stack}-${name}`


        this.launchTemplateId = launchTemplate.id;

Let me know what you guys think. I've had similar issues before and worked around them by refactoring some code but nothing I try here seems to work.
is an
so you cannot treat it like a string. Similarly to a
, you can only access its string value in a callback function within the
method (`sort of like Promise's
Copy code
userData: args.userData.apply(userData => Buffer.from(userData, 'utf8').toString('base64'),
🙌 1
awesome that worked Mike! Thanks so much. I did something similar (though not inline) earlier and I had thought it didn't work but now I wonder if I just forgot to check the latest version in console 😫
p 1
thanks jaxx, I've gotten my head around what Pulumi wants to do the past few weeks, I just couldn't quite figure out what I was doing wrong with the Buffer func here. I did something similar for my container definitions earlier in the week`.apply(([dbConnection, ...]) => JSON.stringify(...)` I probably should of referred back there. Thanks for the help, really do appreciate it.
@billowy-army-68599 thanks for the clarifications here, they helped me out this week. I'm actually learning typescript for the first time through pulumi (zero JS experience either) so I often struggle to even know what I'm supposed to google lol