elegant-crayon-4967
06/22/2021, 9:37 PMinstance = new aws.ec2.instance(.......)
ssmParam = new aws.ssm.Parameter('ssmParam', { name: InstanceParam, value: instance.id }}
little-cartoon-10569
06/22/2021, 9:52 PMacceptable-army-69872
06/22/2021, 10:04 PMelegant-crayon-4967
06/22/2021, 10:06 PMacceptable-army-69872
06/22/2021, 10:07 PMInstanceParam
little-cartoon-10569
06/22/2021, 10:07 PMelegant-crayon-4967
06/22/2021, 10:07 PM"instanceId": "Calling [toJSON] on an [Output<T>] is not supported.\n\nTo get the value of an Output as a JSON value or JSON string consider either:\n 1: o.apply(v => v.toJSON())\n 2: o.apply(v => JSON.stringify(v))\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi.",
little-cartoon-10569
06/22/2021, 10:10 PMaws.ssm.Parameter
isn't working the same as normal Pulumi resource constructors. Let me check the code.elegant-crayon-4967
06/22/2021, 10:11 PMpulumi.all([params, sqlInstance.id]).apply(([paramsOut, sqlInstanceId]) => {
if (element.ssmInstanceConfigParameterName) {
new aws.ssm.Parameter(element.ssmInstanceConfigParameterName, {
name: element.ssmInstanceConfigParameterName,
type: 'String',
overwrite: element.ssmInstanceConfigParameterOverwrite,
value: JSON.stringify({
params: paramsOut,
instanceId: sqlInstanceId,
outputLocation: {
s3BucketName: 'mb-ssm-logs-ec2-sql-infra',
s3KeyPrefix: 'ssm-logs'
},
documentName: associationName,
region: process.env.NODE_CONFIG_REGION
})
});
}
});
little-cartoon-10569
06/22/2021, 10:13 PMbillowy-army-68599
instance.id
to the value
field and it doesn't take an output, you'll need an apply
little-cartoon-10569
06/22/2021, 10:14 PMpulumi.Input<string>
, @billowy-army-68599? At least in parameter.d.ts, it is.elegant-crayon-4967
06/22/2021, 10:15 PMif (element.ssmInstanceConfigParameterName) {
new aws.ssm.Parameter(element.ssmInstanceConfigParameterName, {
name: element.ssmInstanceConfigParameterName,
type: 'String',
overwrite: element.ssmInstanceConfigParameterOverwrite,
value: JSON.stringify({
params: paramsOut,
instanceId: sqlInstance.id,
outputLocation: {
s3BucketName: 'mb-ssm-logs-ec2-sql-infra',
s3KeyPrefix: 'ssm-logs'
},
documentName: associationName,
region: process.env.NODE_CONFIG_REGION
})
});
}
little-cartoon-10569
06/22/2021, 10:15 PMbillowy-army-68599
little-cartoon-10569
06/22/2021, 10:20 PMelegant-crayon-4967
06/22/2021, 10:22 PMlittle-cartoon-10569
06/22/2021, 10:22 PMapply()
code containing a resource constructor, refactor it like this. The dependencies work much better, and so does pulumi preview.elegant-crayon-4967
06/22/2021, 10:23 PMlittle-cartoon-10569
06/22/2021, 10:24 PMgorgeous-country-43026
06/23/2021, 9:00 AMInput
and Output
is possible the hardest in Pulumi to grasp completely but it does make sense and once you get it it is really nice way to handle the problem. It also enables resource wait functionality via dependency tracking which is just pure awesomeness