Skip to content

Commit

Permalink
fix: commands should read region from the AWS config
Browse files Browse the repository at this point in the history
  • Loading branch information
carlsim0n committed Jun 30, 2023
1 parent ec62ce7 commit cd7c691
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/commands/local/listeners/arnListener.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { v4: uuidv4 } = require('uuid');
const AWS = require("aws-sdk");
const websocket = require('./websocket');
let output = console;

async function initArnListener(arn, target, compact, sam, replaySettings, func) {
const token = uuidv4();
const apiId = await websocket.apiId();
websocket.connect(
`wss://${apiId}.execute-api.${process.env.AWS_REGION}.amazonaws.com/Prod`,
`wss://${apiId}.execute-api.${AWS.config.region}.amazonaws.com/Prod`,
token,
null,
compact,
Expand Down
3 changes: 2 additions & 1 deletion src/commands/local/listeners/localPatternListener.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fs = require("fs");
const AWS = require("aws-sdk");
const utils = require("../utils");
const { v4: uuidv4 } = require("uuid");
const YAML = require("yaml-cfn");
Expand Down Expand Up @@ -112,7 +113,7 @@ async function initConnection(
const token = uuidv4();
websocket.connect(
`wss://${await websocket.apiId()}.execute-api.${
process.env.AWS_REGION
AWS.config.region
}.amazonaws.com/Prod`,
token,
ruleName,
Expand Down
3 changes: 2 additions & 1 deletion src/commands/local/listeners/stackListener.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const { v4: uuidv4 } = require('uuid');
const AWS = require("aws-sdk");
const websocket = require('./websocket');

async function initStackListener(stackName, compact, sam) {
const token = uuidv4();
websocket.connect(
`wss://${await websocket.apiId()}.execute-api.${process.env.AWS_REGION}.amazonaws.com/Prod`,
`wss://${await websocket.apiId()}.execute-api.${AWS.config.region}.amazonaws.com/Prod`,
token,
stackName,
compact,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/local/listeners/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async function apiId(cloudFormationClient) {

async function apiUrl() {
return `wss://${await apiId()}.execute-api.${
process.env.AWS_REGION
AWS.config.region
}.amazonaws.com/Prod`;
}

Expand Down
1 change: 0 additions & 1 deletion src/commands/replay-dead-letter/replay-util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const AWS = require("aws-sdk");
const inputUtil = require("../shared/input-util");
const archiveUtil = require("../shared/archive-util");

let eventBridge, sts;
Expand Down
5 changes: 0 additions & 5 deletions src/commands/shared/archive-util.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
const AWS = require("aws-sdk");
const inputUtil = require("./input-util");
const arnListener = require("../local/listeners/arnListener");
const fs = require("fs");
const tempDir = require("temp-dir");
const path = require("path");
const { split } = require("temp-dir");

let eventBridge, sts;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/shared/auth-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require("@mhlabs/aws-sdk-sso");

function initAuth(cmd) {

AWS.config.region = cmd.region || process.env.AWS_REGION || AWS.config.region
AWS.config.region = cmd.region || AWS.config.region || process.env.AWS_REGION
const credentials = new AWS.SharedIniFileCredentials({ profile: cmd.profile });
if (credentials.accessKeyId) {
AWS.config.credentials = credentials;
Expand Down

0 comments on commit cd7c691

Please sign in to comment.