Created
August 27, 2019 11:10
-
-
Save Bonemind/d31cb0b7ab850d4d1564041fec91d3f2 to your computer and use it in GitHub Desktop.
AWS sdk localstack endpoint overrides for nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const AWS = require('aws-sdk'); | |
| debugger; // May need this here so the debugger attaches properly | |
| if (process.env.ENVIRONMENT === 'local') { | |
| console.log('Using localstack endpoints for AWS'); | |
| AWS.config.apigateway = { endpoint: 'http://localhost:4567' }; | |
| AWS.config.kinesis = { endpoint: 'http://localhost:4568' }; | |
| AWS.config.dynamodb = { endpoint: 'http://localhost:4569' }; | |
| AWS.config.dynamodbstreams = { endpoint: 'http://localhost:4570' }; | |
| AWS.config.s3 = { endpoint: 'http://localhost:4572' }; | |
| AWS.config.firehose = { endpoint: 'http://localhost:4573' }; | |
| AWS.config.lambda = { endpoint: 'http://localhost:4574' }; | |
| AWS.config.sns = { endpoint: 'http://localhost:4575' }; | |
| AWS.config.sqs = { endpoint: 'http://localhost:4576' }; | |
| AWS.config.redshift = { endpoint: 'http://localhost:4577' }; | |
| AWS.config.ses = { endpoint: 'http://localhost:4579' }; | |
| AWS.config.route53 = { endpoint: 'http://localhost:4580' }; | |
| AWS.config.cloudformation = { endpoint: 'http://localhost:4581' }; | |
| AWS.config.cloudwatch = { endpoint: 'http://localhost:4582' }; | |
| AWS.config.ssm = { endpoint: 'http://localhost:4583' }; | |
| AWS.config.secretsmanager = { endpoint: 'http://localhost:4584' }; | |
| AWS.config.stepfunctions = { endpoint: 'http://localhost:4585' }; | |
| AWS.config.cloudwatchlogs = { endpoint: 'http://localhost:4586' }; | |
| AWS.config.cloudwatchevents = { endpoint: 'http://localhost:4587' }; | |
| AWS.config.sts = { endpoint: 'http://localhost:4592' }; | |
| AWS.config.iam = { endpoint: 'http://localhost:4593' }; | |
| AWS.config.ec2 = { endpoint: 'http://localhost:4594' }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const InjectPlugin = require('webpack-inject-plugin').default; | |
| const ENTRY_ORDER = require('webpack-inject-plugin').ENTRY_ORDER; | |
| module.exports = { | |
| ... | |
| plugins: [ | |
| new InjectPlugin(function () { | |
| return fs.readFileSync('./aws.endpoints.js'); | |
| }, { | |
| entryOrder: ENTRY_ORDER.First | |
| } | |
| ) | |
| ] | |
| ... | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment