Skip to content

Commit 5ba7da5

Browse files
authored
Migrate to AWS_ENDPOINT_URL (#8)
1 parent 2f5bde9 commit 5ba7da5

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

demos/rds-init-fn-code/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ const fs = require('fs')
77
const path = require('path')
88
require('dotenv').config();
99

10-
// the env LOCALSTACK_HOSTNAME is automatically injected and available
11-
const hostname = process.env.LOCALSTACK_HOSTNAME;
10+
// the env AWS_ENDPOINT_URL is automatically injected and available
11+
const endpoint = process.env.AWS_ENDPOINT_URL;
12+
const url = new URL(endpoint);
13+
const hostname = url.hostname;
1214

1315
// configure the secretsmanager to connect to the running LocalStack instance
1416
const secrets = new AWS.SecretsManager({
15-
endpoint: 'http://' + hostname + ':4566',
17+
endpoint: endpoint,
1618
accessKeyId: 'test',
1719
secretAccessKey: 'test',
1820
region: 'us-east-1',

demos/rds-query-fn-code/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ const mysql = require('mysql2')
22
const AWS = require('aws-sdk')
33
require('dotenv').config();
44

5-
// the env LOCALSTACK_HOSTNAME is automatically injected and available
6-
const hostname = process.env.LOCALSTACK_HOSTNAME;
5+
// the env AWS_ENDPOINT_URL is automatically injected and available
6+
const endpoint = process.env.AWS_ENDPOINT_URL;
7+
const url = new URL(endpoint);
8+
const hostname = url.hostname;
79

810
// configure the secretsmanager to connect to the running LocalStack instance
911
const secrets = new AWS.SecretsManager({
10-
endpoint: 'http://' + hostname + ':4566',
12+
endpoint: endpoint,
1113
accessKeyId: 'test',
1214
secretAccessKey: 'test',
1315
region: 'us-east-1',

0 commit comments

Comments
 (0)