Skip to content

Commit

Permalink
Use current region
Browse files Browse the repository at this point in the history
  • Loading branch information
farski committed Oct 12, 2023
1 parent 27c9629 commit 60e8019
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions spire/templates/apps/dovetail-router.yml
Original file line number Diff line number Diff line change
Expand Up @@ -932,17 +932,17 @@ Resources:
source:
- aws.s3
Handler: index.handler
InlineCode: |
InlineCode: !Sub |
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
const ddb = new AWS.DynamoDB({ region: 'us-east-1' });
const ecs = new AWS.ECS({ region: 'us-east-1' });
const ddb = new AWS.DynamoDB({ region: '${AWS::Region}' });
const ecs = new AWS.ECS({ region: '${AWS::Region}' });
const TABLE_NAME = process.env.DYNAMODB_TABLE_NAME;
const CLUSTER_NAME = process.env.ECS_CLUSTER_NAME;
const SERVICE_NAME = process.env.ECS_SERVICE_NAME;
const SCALE_TO = {
'284/feed-rss.xml': 8,
'815/feed-rss.xml': 4,
'70/feed-rss.xml': 20,
'themoth/feed-rss.xml': 20,
};
Expand All @@ -961,7 +961,7 @@ Resources:
for (const match of matches) {
guids.push(match[1]);
}
console.info(`Read ${guids.length} guids from s3://${Bucket}/${Key}`);
console.info(`Read ${!guids.length} guids from s3://${!Bucket}/${!Key}`);
// break into chunks of 100
const allKeys = guids.map((g) => ({ guid: { S: g } }));
Expand All @@ -978,7 +978,7 @@ Resources:
data.Responses[TABLE_NAME].forEach((r) => (found[r.guid.S] = true));
}
const newGuids = guids.filter((g) => !found[g]);
console.info(`Found ${newGuids.length} new guids not in DDB`);
console.info(`Found ${!newGuids.length} new guids not in DDB`);
// scale ECS service
if (newGuids.length > 0) {
Expand All @@ -987,15 +987,15 @@ Resources:
const count = res.services[0].desiredCount;
const desiredCount = SCALE_TO[Key];
if (count < desiredCount) {
console.info(`Scaling from ${count} to ${desiredCount}`);
console.info(`Scaling from ${!count} to ${!desiredCount}`);
const updateParams = {
cluster: CLUSTER_NAME,
service: SERVICE_NAME,
desiredCount,
};
await ecs.updateService(updateParams).promise();
} else {
console.info(`Already at ${count}`);
console.info(`Already at ${!count}`);
}
}
Expand Down

0 comments on commit 60e8019

Please sign in to comment.