
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@avalabs/country-to-aws-region
Advanced tools
JS library that helps get the closest AWS region from a country code. This library is a copy of [country-to-aws-region](https://github.com/Zeryther/country-to-aws-region)
JS library that helps get the closest AWS region from a country code
I have created this library, as I have faced the issue of targeting specific AWS regional endpoints from a Cloudflare Worker. Cloudflare gives me the user's country code in a request header, so I thought I could use this to my advantage.
This simple library helps you translate a country code to the nearest AWS region. It heavily relies on the Regional Data Centers mapping made by the TurnKey Linux team. You can find their repository here. They also published an article about it here.
npm i country-to-aws-region
import { countryToAwsRegion } from 'country-to-aws-region';
const countryCode = 'DE'; // Get the country code from your request headers for example
console.log(countryToAwsRegion(countryCode)); // eu-central-1
Sometimes, you only want specific AWS regions to be available. In that case, you can pass an array of regions as the second parameter. The function will filter out all regions that do not match.
import { countryToAwsRegion } from 'country-to-aws-region';
const countryCode = 'DE'; // Get the country code from your request headers for example
const regions = ['us-east-2', 'af-south-1'];
console.log(countryToAwsRegion(countryCode, regions)); // us-east-2
This repository contains an automatic script that will fetch and parse the data from the TurnKey Linux repository:
npm run update-data
This library is a copy of country-to-aws-region
This program was created and published by Mehdi Baaboura under the MIT License.
FAQs
JS library that helps get the closest AWS region from a country code. This library is a copy of [country-to-aws-region](https://github.com/Zeryther/country-to-aws-region)
We found that @avalabs/country-to-aws-region demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.