Skip to content

Commit

Permalink
Upgraded packages, fixed bug w/ fetching Lambda IP ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
heythisischris committed Jun 17, 2024
1 parent e97d101 commit 922f725
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 259 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
},
"type": "module",
"dependencies": {
"@notionhq/client": "^2.2.13",
"@notionhq/client": "^2.2.15",
"aws-jwt-verify": "^4.0.1",
"chrono-node": "^2.7.5",
"fast-xml-parser": "^4.3.4",
"openai": "^4.28.0",
"serverless-postgres": "^2.1.0",
"string-strip-html": "^13.4.6",
"stripe": "^14.18.0"
"chrono-node": "^2.7.6",
"fast-xml-parser": "^4.4.0",
"openai": "^4.51.0",
"serverless-postgres": "^2.1.1",
"string-strip-html": "^13.4.8",
"stripe": "^15.11.0"
},
"devDependencies": {
"esbuild": "^0.19.5"
"esbuild": "^0.21.5"
}
}
9 changes: 7 additions & 2 deletions routes/scheduled/runEveryMinute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ export const runEveryMinute = async () => {
// Sync IP Ranges
const newIps = (await (await fetch(`https://ip-ranges.amazonaws.com/ip-ranges.json`)).json()).prefixes
.filter(({ region, service }) => region === 'us-east-2' && service === 'EC2').map(obj => obj.ip_prefix);
const existingIps = (await ec2Client.send(new DescribeSecurityGroupsCommand({ GroupIds: [process.env.DB_SECURITY_GROUP] })))
.SecurityGroups?.map(securityGroup => securityGroup?.IpPermissions?.map(ipPermission => ipPermission.IpRanges?.map(ipRange => ipRange.CidrIp)).flat()).flat();
const existingIps = (await ec2Client.send(new DescribeSecurityGroupsCommand({ GroupIds: [process.env.DB_SECURITY_GROUP] }))).SecurityGroups
.map(securityGroup => securityGroup.IpPermissions
.map(ipPermission => ipPermission.IpRanges
.filter(obj => obj.Description === 'Lambda')
.map(ipRange => ipRange.CidrIp)
).flat()
).flat();
const addedIps = newIps.filter(newIp => !existingIps.includes(newIp));
const removedIps = existingIps.filter(existingIp => !newIps.includes(existingIp));
if (removedIps.length > 0) {
Expand Down
Loading

0 comments on commit 922f725

Please sign in to comment.