brave-angle-33257
04/21/2020, 6:31 PMgetOutputSync
get removed in pulumi 2.0.0 ??red-match-15116
04/21/2020, 6:32 PMbrave-angle-33257
04/21/2020, 6:34 PMvar indexes = <Promise<string[]>>this.dynamodb.getOutputValue('index_names');
for ( let table of Object.keys(indexes) ) {
TypeError: indexes is not iterable
red-match-15116
04/21/2020, 6:49 PMbrave-angle-33257
04/21/2020, 6:52 PMroot@c8add1fb4b84:/data/pulumi/infra/aws/company/environment/company-dynamo-tables# pulumi stack output | grep names
index_names {"order":["status-uid"],"user":["email"]}
table_names ["order", "user"]
/// alarms
for ( let table of Object.keys(indexes) ) {
for ( let index of indexes[table]) {
var alarm_name = `${this.prefix}-dynamodb-read-throttle-${table}-index-${index}`;
var alarm = new aws.cloudwatch.MetricAlarm(alarm_name, {
name: alarm_name,
namespace: `AWS/DynamoDB`,
comparisonOperator: 'GreaterThanOrEqualToThreshold',
threshold: threshold,
statistic: 'Sum',
period: period,
evaluationPeriods: evaluationPeriods,
treatMissingData: 'notBreaching',
metricName: 'ReadThrottleEvents',
alarmActions: alarm_actions,
dimensions: {
TableName: `${this.env}-${this.company}-${table}`,
GlobalSecondaryIndexName: `index-${index}`
}
});
alarms.push(alarm);
}
}
this
when I previously tried to loop through the outputs using an apply() i had scope issues getting the object params into the closure function, it just seemed like this was an ideal/easy use case to simply synchronously get the outputs and iterate on a loop.push
didn't work either due to the order of operations and they hadnt been created yet to output the alarm names for when I wanted to composite alarm them/// DYNAMO TABLES
var dynamodb_composite = alarm.dynamodb_composite_alarm([
alarm.dynamodb_user_errors_alarm(),
alarm.dynamodb_throttle_alarm(),
alarm.dynamodb_capacity_alarm()
], [action_critical]);
red-match-15116
04/21/2020, 7:28 PMbrave-angle-33257
04/21/2020, 7:29 PM// outputs from python - <https://github.com/pulumi/pulumi/issues/4462>
if ( typeof(process.env['TABLE_NAMES']) === 'undefined' ) {
console.log("TABLE_NAMES env var missing! Please specify it with `pulumi up`");
}
if ( typeof(process.env['INDEX_NAMES']) === 'undefined' ) {
console.log("INDEX_NAMES env var missing! Please specify it with `pulumi up`");
}
this.table_names = JSON.parse(String(process.env['TABLE_NAMES']));
this.index_names = JSON.parse(String(process.env['INDEX_NAMES']));
# select dynamo stack
cmd_list = [
"pulumi",
"stack",
"select",
s['stack']
]
if co.debug:
print("[DEBUG] - Select Dynamo Stack CMD: {}".format(cmd_list))
check_output(cmd_list, cwd=full_cwd_dynamo)
# get dynamo outputs
cmd_list = [
"pulumi",
"stack",
"output",
"-j"
]
if co.debug:
print("[DEBUG] - Get Dynamo Outputs CMD: {}".format(cmd_list))
outputs = json.loads(check_output(cmd_list, cwd=full_cwd_dynamo).decode('utf8').strip())
# Update alarms stack
cmd = "TABLE_NAMES='{}' INDEX_NAMES='{}' pulumi update --yes".format(
json.dumps(outputs['table_names']),
json.dumps(outputs['index_names'])
)
if co.debug:
print("[DEBUG] - Update Alarms Stack CMD: {}".format(cmd))
check_output(cmd, shell=True, cwd=full_cwd)
gorgeous-egg-16927
04/21/2020, 8:22 PM