Skip to content

Commit 5383b19

Browse files
Add logic to fetch dev endpoint from local package (#176)
* Add logic to fetch dev endpoint from local package * Use initialization options for endpoint config --------- Co-authored-by: Kevin DeJong <kddejong@amazon.com>
1 parent 8aee059 commit 5383b19

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/server/CfnExternal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class CfnExternal implements Configurables, Closeable {
3636
readonly featureFlags: FeatureFlagProvider;
3737

3838
constructor(lsp: LspComponents, core: CfnInfraCore, overrides: Partial<CfnExternal> = {}) {
39-
this.awsClient = overrides.awsClient ?? new AwsClient(core.awsCredentials);
39+
this.awsClient = overrides.awsClient ?? new AwsClient(core.awsCredentials, core.cloudformationEndpoint);
4040

4141
this.cfnService = overrides.cfnService ?? new CfnService(this.awsClient);
4242
this.ccapiService = overrides.ccapiService ?? new CcapiService(this.awsClient);

src/server/CfnInfraCore.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import { Configurable, Configurables } from '../utils/Configurable';
1616

1717
interface ExtendedInitializeParams extends InitializeParams {
1818
initializationOptions?: {
19+
aws?: {
20+
cloudformation?: {
21+
endpoint?: string;
22+
};
23+
};
1924
encryption?: {
2025
key?: string;
2126
};
@@ -40,6 +45,7 @@ export class CfnInfraCore implements Configurables, Closeable {
4045

4146
readonly awsCredentials: AwsCredentials;
4247
readonly diagnosticCoordinator: DiagnosticCoordinator;
48+
readonly cloudformationEndpoint?: string;
4349

4450
constructor(
4551
lspComponents: LspComponents,
@@ -59,6 +65,7 @@ export class CfnInfraCore implements Configurables, Closeable {
5965
this.contextManager = overrides.contextManager ?? new ContextManager(this.syntaxTreeManager);
6066
this.fileContextManager = overrides.fileContextManager ?? new FileContextManager(this.documentManager);
6167

68+
this.cloudformationEndpoint = initializeParams.initializationOptions?.aws?.cloudformation?.endpoint;
6269
const encryptionKey = initializeParams.initializationOptions?.encryption?.key;
6370

6471
this.awsCredentials =

src/services/AwsClient.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ type IamClientConfig = {
99
region: string;
1010
credentials: IamCredentials;
1111
customUserAgent: string;
12+
endpoint?: string;
1213
};
1314

1415
export class AwsClient {
15-
constructor(private readonly credentialsProvider: AwsCredentials) {}
16+
constructor(
17+
private readonly credentialsProvider: AwsCredentials,
18+
private readonly cloudformationEndpoint?: string,
19+
) {}
1620

1721
// By default, clients will retry on throttling exceptions 3 times
1822
public getCloudFormationClient() {
@@ -34,6 +38,7 @@ export class AwsClient {
3438
region: credential.region,
3539
credentials: credential,
3640
customUserAgent: `${ExtensionId}/${ExtensionVersion}`,
41+
endpoint: this.cloudformationEndpoint,
3742
};
3843
} catch {
3944
throw new Error('AWS credentials not configured. Authentication required for online features.');

0 commit comments

Comments
 (0)