calm-parrot-72437
09/15/2020, 5:18 PMgreen-school-95910
09/15/2020, 5:21 PMlemon-agent-27707
09/15/2020, 5:22 PMgreen-school-95910
09/15/2020, 5:22 PMclever-sunset-76585
09/15/2020, 5:24 PMInstance
resource inside apply()
is not ideal. You should be able to pass the password
as an input straight to whichever property uses that value in new aws.ec2.Instance(…)
.
Basically, do this:
const instance = new aws.ec2.Instance("", {
someProp: password <--
});
for a quick workaround with the code you already have, you can run pulumi stack output --show-secrets
to reveal secret values in the command-line.calm-parrot-72437
09/15/2020, 5:35 PMstart ${password}
,
},
},
},
},
),
});
..but the pulumi update details showed the userData created by pcloudinit package had pulumi warnings in it, so figured i had messed upclever-sunset-76585
09/15/2020, 5:38 PMcalm-parrot-72437
09/15/2020, 5:41 PMstart ${password}
? typescript doesn't like that, it wants a string for command not an Output<string>green-school-95910
09/15/2020, 6:01 PMcreateUserData
function come from?clever-sunset-76585
09/15/2020, 6:02 PMpulumi.interpolate
which is Output
-aware.
const instance = new aws.ec2.Instance(appName, {
userData: createUserData(
["start_license_server"],
{
"start_license_server": {
commands: {
"01_start_server": {
command: pulumi.interpolate `start ${password}`,
},
},
},
},
),
});
I am not sure what your createUserData
function does, so I can’t guarantee ☝️ will work straightaway.green-school-95910
09/15/2020, 6:09 PMuserData
is string instead of Input<string>
. So typescript will reject it: https://www.pulumi.com/docs/reference/pkg/aws/ec2/instance/#userdata_nodejscalm-parrot-72437
09/15/2020, 6:14 PMclever-sunset-76585
09/15/2020, 6:19 PMInput
or Output
, but in fact userData
property of InstanceArgs
is of type Input<string>
. Here’s the nodejs docs for that: https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/aws/ec2/#InstanceArgs-userDatagreen-school-95910
09/15/2020, 6:22 PMcalm-parrot-72437
09/15/2020, 6:26 PMclever-sunset-76585
09/15/2020, 6:27 PMcommand
property only takes a string as you called out, so yeah you are back to transforming the output property with an apply. Can you try this?
const userData = password.apply(p => {
createUserData(
["start_license_server"],
{
"start_license_server": {
commands: {
"01_start_server": {
command: `start ${p}`,
},
},
},
},
)
});
const instance = new aws.ec2.Instance(appName, {
userData,
});
calm-parrot-72437
09/15/2020, 6:27 PMclever-sunset-76585
09/15/2020, 6:55 PM