Skip to content

Commit

Permalink
fix: support deployments with different vendor prefixes on a single A…
Browse files Browse the repository at this point in the history
…WS account
  • Loading branch information
tjanczuk committed Jan 20, 2024
1 parent a7b7326 commit 1af9955
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion apps/ops/src/aws/apprunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ export async function listLetsGoAppRunnerServices(
while (true) {
const result = await apprunner.send(new ListServicesCommand(listInput));
for (const service of result.ServiceSummaryList || []) {
if (service.ServiceName?.startsWith(VendorPrefix)) {
if (service.ServiceName?.startsWith(`${VendorPrefix}-`)) {
const listTagsCommand = new ListTagsForResourceCommand({
ResourceArn: service.ServiceArn || "",
});
Expand Down
46 changes: 27 additions & 19 deletions packages/queue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import {
SQSClient,
SendMessageCommand,
} from "@aws-sdk/client-sqs";
import { DefaultRegion, DefaultDeployment, TagKeys } from "@letsgo/constants";
import {
DefaultRegion,
DefaultDeployment,
TagKeys,
VendorPrefix,
} from "@letsgo/constants";
import { Message } from "@letsgo/types";
import http from "http";

Expand Down Expand Up @@ -47,24 +52,27 @@ export async function listLetsGoQueues(
while (true) {
const result = await sqs.send(new ListQueuesCommand(listInput));
for (const queueUrl of result.QueueUrls || []) {
const listTagsCommand = new ListQueueTagsCommand({
QueueUrl: queueUrl,
});
try {
const tagsResult = await sqs.send(listTagsCommand);
const deploymentValue = tagsResult.Tags?.[TagKeys.LetsGoDeployment];
if (
deploymentValue &&
(!deployment || deployment === deploymentValue)
) {
queues.push(queueUrl);
}
} catch (e: any) {
if (
e.name !== "AWS.SimpleQueueService.NonExistentQueue" &&
e.name !== "QueueDoesNotExist"
) {
throw e;
const queueName = queueUrl.split("/").pop();
if (queueName?.startsWith(`${VendorPrefix}-`)) {
const listTagsCommand = new ListQueueTagsCommand({
QueueUrl: queueUrl,
});
try {
const tagsResult = await sqs.send(listTagsCommand);
const deploymentValue = tagsResult.Tags?.[TagKeys.LetsGoDeployment];
if (
deploymentValue &&
(!deployment || deployment === deploymentValue)
) {
queues.push(queueUrl);
}
} catch (e: any) {
if (
e.name !== "AWS.SimpleQueueService.NonExistentQueue" &&
e.name !== "QueueDoesNotExist"
) {
throw e;
}
}
}
}
Expand Down

0 comments on commit 1af9955

Please sign in to comment.