Skip to content

Commit f77b0ba

Browse files
committed
chore: run dns check upon reconfiguring aws-profile
1 parent 4a4866a commit f77b0ba

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/utils/configure-aws.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,23 @@ function isValidEndpointUrl(url: string | undefined): boolean {
6868
}
6969
}
7070

71-
function checkIfConfigNeedsOverride(section: IniSection | undefined): boolean {
71+
async function checkIfConfigNeedsOverride(
72+
section: IniSection | undefined,
73+
): Promise<boolean> {
7274
if (!section) {
7375
return true; // profile doesn't exist
7476
}
7577

78+
if (
79+
section.properties.endpoint_url === "http://localhost.localstack.cloud:4566"
80+
) {
81+
const isDnsResolved = await dnsResolveCheck(undefined);
82+
if (!isDnsResolved) {
83+
// if DNS is not resolved, we need to override the endpoint_url
84+
return true;
85+
}
86+
}
87+
7688
return !(
7789
section.properties.region &&
7890
section.properties.endpoint_url &&
@@ -317,7 +329,7 @@ export async function configureAwsProfiles(options: {
317329
let configModified: boolean | undefined;
318330
let credentialsModified: boolean | undefined;
319331

320-
const configNeedsOverride = checkIfConfigNeedsOverride(configSection);
332+
const configNeedsOverride = await checkIfConfigNeedsOverride(configSection);
321333
const credentialsNeedsOverride =
322334
checkIfCredentialsNeedsOverride(credentialsSection);
323335

0 commit comments

Comments
 (0)