mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-19 04:17:44 +00:00
fix typo: change AWS_SNS_TOPIC_ARM to AWS_SNS_TOPIC_ARN (#1093)
This commit is contained in:
@@ -13,7 +13,7 @@ Configuration is provided via environment variables:
|
|||||||
|AWS_ACCESS_KEY_ID| aws access key id, used for TTS/STT as well SNS notifications|no|
|
|AWS_ACCESS_KEY_ID| aws access key id, used for TTS/STT as well SNS notifications|no|
|
||||||
|AWS_REGION| aws region| no|
|
|AWS_REGION| aws region| no|
|
||||||
|AWS_SECRET_ACCESS_KEY| aws secret access key, used per above|no|
|
|AWS_SECRET_ACCESS_KEY| aws secret access key, used per above|no|
|
||||||
|AWS_SNS_TOPIC_ARM| aws sns topic arn that scale-in lifecycle notifications will be published to|no|
|
|AWS_SNS_TOPIC_ARN| aws sns topic arn that scale-in lifecycle notifications will be published to|no|
|
||||||
|DRACHTIO_HOST| ip address of drachtio server (typically '127.0.0.1')|yes|
|
|DRACHTIO_HOST| ip address of drachtio server (typically '127.0.0.1')|yes|
|
||||||
|DRACHTIO_PORT| listening port of drachtio server for control connections (typically 9022)|yes|
|
|DRACHTIO_PORT| listening port of drachtio server for control connections (typically 9022)|yes|
|
||||||
|DRACHTIO_SECRET| shared secret|yes|
|
|DRACHTIO_SECRET| shared secret|yes|
|
||||||
@@ -72,7 +72,7 @@ module.exports = {
|
|||||||
STATS_PORT: 8125,
|
STATS_PORT: 8125,
|
||||||
STATS_PROTOCOL: 'tcp',
|
STATS_PROTOCOL: 'tcp',
|
||||||
STATS_TELEGRAF: 1,
|
STATS_TELEGRAF: 1,
|
||||||
AWS_SNS_TOPIC_ARM: 'arn:aws:sns:us-west-1:xxxxxxxxxxx:terraform-20201107200347128600000002',
|
AWS_SNS_TOPIC_ARN: 'arn:aws:sns:us-west-1:xxxxxxxxxxx:terraform-20201107200347128600000002',
|
||||||
JAMBONES_NETWORK_CIDR: '172.31.0.0/16',
|
JAMBONES_NETWORK_CIDR: '172.31.0.0/16',
|
||||||
JAMBONES_MYSQL_HOST: 'aurora-cluster-jambonz.cluster-yyyyyyyyyyy.us-west-1.rds.amazonaws.com',
|
JAMBONES_MYSQL_HOST: 'aurora-cluster-jambonz.cluster-yyyyyyyyyyy.us-west-1.rds.amazonaws.com',
|
||||||
JAMBONES_MYSQL_USER: 'admin',
|
JAMBONES_MYSQL_USER: 'admin',
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ const AWS_REGION = process.env.AWS_REGION;
|
|||||||
const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
|
const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
|
||||||
const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
|
const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
|
||||||
const AWS_SNS_PORT = parseInt(process.env.AWS_SNS_PORT, 10) || 3001;
|
const AWS_SNS_PORT = parseInt(process.env.AWS_SNS_PORT, 10) || 3001;
|
||||||
const AWS_SNS_TOPIC_ARM = process.env.AWS_SNS_TOPIC_ARM;
|
const AWS_SNS_TOPIC_ARN = process.env.AWS_SNS_TOPIC_ARN;
|
||||||
const AWS_SNS_PORT_MAX = parseInt(process.env.AWS_SNS_PORT_MAX, 10) || 3005;
|
const AWS_SNS_PORT_MAX = parseInt(process.env.AWS_SNS_PORT_MAX, 10) || 3005;
|
||||||
|
|
||||||
const GCP_JSON_KEY = process.env.GCP_JSON_KEY;
|
const GCP_JSON_KEY = process.env.GCP_JSON_KEY;
|
||||||
@@ -189,7 +189,7 @@ module.exports = {
|
|||||||
AWS_ACCESS_KEY_ID,
|
AWS_ACCESS_KEY_ID,
|
||||||
AWS_SECRET_ACCESS_KEY,
|
AWS_SECRET_ACCESS_KEY,
|
||||||
AWS_SNS_PORT,
|
AWS_SNS_PORT,
|
||||||
AWS_SNS_TOPIC_ARM,
|
AWS_SNS_TOPIC_ARN,
|
||||||
AWS_SNS_PORT_MAX,
|
AWS_SNS_PORT_MAX,
|
||||||
|
|
||||||
ANCHOR_MEDIA_ALWAYS,
|
ANCHOR_MEDIA_ALWAYS,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const assert = require('assert');
|
|||||||
const {
|
const {
|
||||||
AWS_REGION,
|
AWS_REGION,
|
||||||
AWS_SNS_PORT: PORT,
|
AWS_SNS_PORT: PORT,
|
||||||
AWS_SNS_TOPIC_ARM,
|
AWS_SNS_TOPIC_ARN,
|
||||||
AWS_SNS_PORT_MAX,
|
AWS_SNS_PORT_MAX,
|
||||||
} = require('../config');
|
} = require('../config');
|
||||||
const {LifeCycleEvents} = require('./constants');
|
const {LifeCycleEvents} = require('./constants');
|
||||||
@@ -55,12 +55,12 @@ class SnsNotifier extends Emitter {
|
|||||||
async _handlePost(req, res) {
|
async _handlePost(req, res) {
|
||||||
try {
|
try {
|
||||||
const parsedBody = JSON.parse(req.body);
|
const parsedBody = JSON.parse(req.body);
|
||||||
this.logger.debug({headers: req.headers, body: parsedBody}, 'Received HTTP POST from AWS');
|
this.logger.info({headers: req.headers, body: parsedBody}, 'Received HTTP POST from AWS');
|
||||||
if (!validatePayload(parsedBody)) {
|
if (!validatePayload(parsedBody)) {
|
||||||
this.logger.info('incoming AWS SNS HTTP POST failed signature validation');
|
this.logger.info('incoming AWS SNS HTTP POST failed signature validation');
|
||||||
return res.sendStatus(403);
|
return res.sendStatus(403);
|
||||||
}
|
}
|
||||||
this.logger.debug('incoming HTTP POST passed validation');
|
this.logger.info('incoming HTTP POST passed validation');
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
|
|
||||||
switch (parsedBody.Type) {
|
switch (parsedBody.Type) {
|
||||||
@@ -74,7 +74,18 @@ class SnsNotifier extends Emitter {
|
|||||||
subscriptionRequestId: this.subscriptionRequestId
|
subscriptionRequestId: this.subscriptionRequestId
|
||||||
}, 'response from SNS SubscribeURL');
|
}, 'response from SNS SubscribeURL');
|
||||||
const data = await this.describeInstance();
|
const data = await this.describeInstance();
|
||||||
this.lifecycleState = data.AutoScalingGroups[0].Instances[0].LifecycleState;
|
|
||||||
|
const group = data.AutoScalingGroups.find((group) =>
|
||||||
|
group.Instances && group.Instances.some((instance) => instance.InstanceId === this.instanceId)
|
||||||
|
);
|
||||||
|
if (!group) {
|
||||||
|
this.logger.error('Current instance not found in any Auto Scaling group', data);
|
||||||
|
} else {
|
||||||
|
const instance = group.Instances.find((instance) => instance.InstanceId === this.instanceId);
|
||||||
|
this.lifecycleState = instance.LifecycleState;
|
||||||
|
}
|
||||||
|
|
||||||
|
//this.lifecycleState = data.AutoScalingGroups[0].Instances[0].LifecycleState;
|
||||||
this.emit('SubscriptionConfirmation', {publicIp: this.publicIp});
|
this.emit('SubscriptionConfirmation', {publicIp: this.publicIp});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -94,7 +105,7 @@ class SnsNotifier extends Emitter {
|
|||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.logger.debug(`SnsNotifier - instance ${msg.EC2InstanceId} is scaling in (not us)`);
|
this.logger.info(`SnsNotifier - instance ${msg.EC2InstanceId} is scaling in (not us)`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -111,7 +122,7 @@ class SnsNotifier extends Emitter {
|
|||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
try {
|
try {
|
||||||
this.logger.debug('SnsNotifier: retrieving instance data');
|
this.logger.info('SnsNotifier: retrieving instance data');
|
||||||
this.instanceId = await getString('http://169.254.169.254/latest/meta-data/instance-id');
|
this.instanceId = await getString('http://169.254.169.254/latest/meta-data/instance-id');
|
||||||
this.publicIp = await getString('http://169.254.169.254/latest/meta-data/public-ipv4');
|
this.publicIp = await getString('http://169.254.169.254/latest/meta-data/public-ipv4');
|
||||||
this.logger.info({
|
this.logger.info({
|
||||||
@@ -142,13 +153,13 @@ class SnsNotifier extends Emitter {
|
|||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
Protocol: 'http',
|
Protocol: 'http',
|
||||||
TopicArn: AWS_SNS_TOPIC_ARM,
|
TopicArn: AWS_SNS_TOPIC_ARN,
|
||||||
Endpoint: this.snsEndpoint
|
Endpoint: this.snsEndpoint
|
||||||
};
|
};
|
||||||
const response = await snsClient.send(new SubscribeCommand(params));
|
const response = await snsClient.send(new SubscribeCommand(params));
|
||||||
this.logger.info({response}, `response to SNS subscribe to ${AWS_SNS_TOPIC_ARM}`);
|
this.logger.info({response}, `response to SNS subscribe to ${AWS_SNS_TOPIC_ARN}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error({err}, `Error subscribing to SNS topic arn ${AWS_SNS_TOPIC_ARM}`);
|
this.logger.error({err}, `Error subscribing to SNS topic arn ${AWS_SNS_TOPIC_ARN}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,9 +170,9 @@ class SnsNotifier extends Emitter {
|
|||||||
SubscriptionArn: this.subscriptionArn
|
SubscriptionArn: this.subscriptionArn
|
||||||
};
|
};
|
||||||
const response = await snsClient.send(new UnsubscribeCommand(params));
|
const response = await snsClient.send(new UnsubscribeCommand(params));
|
||||||
this.logger.info({response}, `response to SNS unsubscribe to ${AWS_SNS_TOPIC_ARM}`);
|
this.logger.info({response}, `response to SNS unsubscribe to ${AWS_SNS_TOPIC_ARN}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error({err}, `Error unsubscribing to SNS topic arn ${AWS_SNS_TOPIC_ARM}`);
|
this.logger.error({err}, `Error unsubscribing to SNS topic arn ${AWS_SNS_TOPIC_ARN}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const {
|
|||||||
JAMBONES_SBCS,
|
JAMBONES_SBCS,
|
||||||
K8S,
|
K8S,
|
||||||
K8S_SBC_SIP_SERVICE_NAME,
|
K8S_SBC_SIP_SERVICE_NAME,
|
||||||
AWS_SNS_TOPIC_ARM,
|
AWS_SNS_TOPIC_ARN,
|
||||||
OPTIONS_PING_INTERVAL,
|
OPTIONS_PING_INTERVAL,
|
||||||
AWS_REGION,
|
AWS_REGION,
|
||||||
NODE_ENV,
|
NODE_ENV,
|
||||||
@@ -35,7 +35,7 @@ module.exports = (logger) => {
|
|||||||
// listen for SNS lifecycle changes
|
// listen for SNS lifecycle changes
|
||||||
let lifecycleEmitter = new Emitter();
|
let lifecycleEmitter = new Emitter();
|
||||||
let dryUpCalls = false;
|
let dryUpCalls = false;
|
||||||
if (AWS_SNS_TOPIC_ARM && AWS_REGION) {
|
if (AWS_SNS_TOPIC_ARN && AWS_REGION) {
|
||||||
|
|
||||||
(async function() {
|
(async function() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user