Skip to content

Commit e58fed5

Browse files
authored
Migrate to AWS_ENDPOINT_URL (#73)
1 parent 43f0e84 commit e58fed5

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

demo/lambdas/app.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
const uuidv4 = require('uuid/v4');
22
const AWS = require('aws-sdk');
33

4-
const LOCALSTACK_HOSTNAME = process.env.LOCALSTACK_HOSTNAME;
5-
const ENDPOINT = `http://${LOCALSTACK_HOSTNAME}:4566`;
6-
if (LOCALSTACK_HOSTNAME) {
4+
const AWS_ENDPOINT_URL = process.env.AWS_ENDPOINT_URL;
5+
if (AWS_ENDPOINT_URL) {
76
process.env.AWS_SECRET_ACCESS_KEY = 'test';
87
process.env.AWS_ACCESS_KEY_ID = 'test';
98
}
109

1110
const DYNAMODB_TABLE = 'appRequests';
1211
const QUEUE_NAME = 'requestQueue';
13-
const CLIENT_CONFIG = LOCALSTACK_HOSTNAME ? {endpoint: ENDPOINT} : {};
12+
const CLIENT_CONFIG = AWS_ENDPOINT_URL ? {endpoint: AWS_ENDPOINT_URL} : {};
1413

1514
const connectSQS = () => new AWS.SQS(CLIENT_CONFIG);
1615
const connectDynamoDB = () => new AWS.DynamoDB(CLIENT_CONFIG);

demo/lambdas/processing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import datetime
12
import os
23
import time
34
import uuid
4-
import datetime
5+
56
import boto3
67

7-
LOCALSTACK_HOSTNAME = os.environ.get("LOCALSTACK_HOSTNAME")
8-
ENDPOINT = f'http://{LOCALSTACK_HOSTNAME}:4566'
8+
AWS_ENDPOINT_URL = os.environ.get("AWS_ENDPOINT_URL")
99

1010
DYNAMODB_TABLE = 'appRequests'
1111
S3_BUCKET = os.environ.get('ARCHIVE_BUCKET') or 'archive-bucket'
@@ -43,7 +43,7 @@ def archive_result(event, context=None):
4343

4444

4545
def get_client(resource):
46-
kwargs = {"endpoint_url": ENDPOINT} if LOCALSTACK_HOSTNAME else {}
46+
kwargs = {"endpoint_url": AWS_ENDPOINT_URL} if AWS_ENDPOINT_URL else {}
4747
return boto3.client(resource, **kwargs)
4848

4949

demo/lambdas/worker.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
require 'aws-sdk-states'
22

3-
$localstack_hostname = ENV['LOCALSTACK_HOSTNAME']
4-
$endpoint = "http://#{$localstack_hostname}:4566"
5-
if $localstack_hostname
3+
$aws_endpoint_url = ENV['AWS_ENDPOINT_URL']
4+
if $aws_endpoint_url
65
ENV['AWS_SECRET_ACCESS_KEY'] = 'test'
76
ENV['AWS_ACCESS_KEY_ID'] = 'test'
87
end
98
$state_machine_arn = ENV['STATE_MACHINE_ARN']
109

1110
def triggerProcessing(event:, context:)
12-
if $localstack_hostname
13-
client = Aws::States::Client.new(:endpoint => $endpoint)
11+
if $aws_endpoint_url
12+
client = Aws::States::Client.new(:endpoint => $aws_endpoint_url)
1413
else
1514
client = Aws::States::Client.new()
1615
end

0 commit comments

Comments
 (0)