Skip to content
file

GitHub Action

AWS region reduction map

0.2.1 Latest version
Use latest version
file

AWS region reduction map

Converts AWS region names from full names to either "fixed" or "short" abbreviations

Installation

Copy and paste the following snippet into your .yml file.

- name: AWS region reduction map
  uses: cloudposse/github-action-aws-region-reduction-map@0.2.1
Learn more about this action in cloudposse/github-action-aws-region-reduction-map
Choose a version

github-action-aws-region-reduction-map

Latest Release Slack Community

README Header

Cloud Posse

Converts AWS region names from full names to abbreviations


This project is part of our comprehensive "SweetOps" approach towards DevOps.

It's 100% Open Source and licensed under the APACHE2.

Introduction

Converts AWS region names from full names to either "fixed" (always 3 characters) or "short" (usually 4 or 5 characters) abbreviations, following the same map as https://github.com/cloudposse/terraform-aws-utils

Short abbreviations are generally the same as official AWS availability zone IDs.

Generally, AWS region names have 3 parts and the "fixed" abbreviation is the first character of each part. Exceptions (due to collisions):

  • Africa and China use second letter of first part.
  • ap-south-1 is shortened to as0 to avoid conflict with ap-southeast-1
  • cn-north-1 is shortened to nn0 to avoid conflict with cn-northwest-1

You should be able to list all regions with this command:

aws ec2 describe-regions --all-regions --query "Regions[].{Name:RegionName}" --output text

but actually it leaves out GovCloud and China See https://github.com/jsonmaur/aws-regions for more complete list

long fixed short
ap-east-1 ae1 ape1
ap-northeast-1 an1 apne1
ap-northeast-2 an2 apne2
ap-northeast-3 an3 apne3
ap-south-1 as0 aps1
ap-southeast-1 as1 apse1
ap-southeast-2 as2 apse2
ca-central-1 cc1 cac1
eu-central-1 ec1 euc1
eu-north-1 en1 eun1
eu-south-1 es1 eus1
eu-west-1 ew1 euw1
eu-west-2 ew2 euw2
eu-west-3 ew3 euw3
af-south-1 fs1 afs1
us-gov-east-1 ge1 usge1
us-gov-west-1 gw1 usgw1
me-south-1 ms1 mes1
cn-north-1 nn0 cnn1
cn-northwest-1 nn1 cnnw1
sa-east-1 se1 sae1
us-east-1 ue1 use1
us-east-2 ue2 use2
us-west-1 uw1 usw1
us-west-2 uw2 usw2

Usage

Convert AWS region (ex.: us-west-2) to fixed abbreviation - will be uw2.

  name: Pull Request
  on:
    pull_request:
      branches: [ 'main' ]
      types: [opened, synchronize, reopened, closed, labeled, unlabeled]

  jobs:
    context:
      runs-on: ubuntu-latest
      steps:
        - uses: cloudposse/github-action-aws-region-reduction-map@main
          id: aws_map
          with:
            region: 'us-west-2'
            ## Format can be skipped - default format would be `fixed` if region is long 
            format: 'fixed'

      outputs:
        result: ${{ steps.aws_map.outputs.result }}

Convert AWS region (ex.: us-west-2) to short abbreviation - will be usw2.

  name: Pull Request
  on:
    pull_request:
      branches: [ 'main' ]
      types: [opened, synchronize, reopened, closed, labeled, unlabeled]

  jobs:
    context:
      runs-on: ubuntu-latest
      steps:
        - uses: cloudposse/github-action-aws-region-reduction-map@main
          id: aws_map
          with:
            region: 'us-west-2'
            format: 'short'

      outputs:
        result: ${{ steps.aws_map.outputs.result }}

Convert short AWS region (ex.: usw2) to long abbreviation - will be us-west-2.

  name: Pull Request
  on:
    pull_request:
      branches: [ 'main' ]
      types: [opened, synchronize, reopened, closed, labeled, unlabeled]

  jobs:
    context:
      runs-on: ubuntu-latest
      steps:
        - uses: cloudposse/github-action-aws-region-reduction-map@main
          id: aws_map
          with:
            region: 'usw2'
            format: 'long'

      outputs:
        result: ${{ steps.aws_map.outputs.result }}

Convert fixed AWS region (ex.: uw2) to long abbreviation - will be us-west-2.

  name: Pull Request
  on:
    pull_request:
      branches: [ 'main' ]
      types: [opened, synchronize, reopened, closed, labeled, unlabeled]

  jobs:
    context:
      runs-on: ubuntu-latest
      steps:
        - uses: cloudposse/github-action-aws-region-reduction-map@main
          id: aws_map
          with:
            region: 'uw2'
            format: 'long'

      outputs:
        result: ${{ steps.aws_map.outputs.result }}

Inputs

Name Description Default Required
format Format convert to. Valid values ('long', 'short', 'fixed').
If empty short and fixed inputs are converted to long, long inputs are converted to fixed.
N/A false
region Input region code N/A true

Outputs

Name Description
result Converted AWS region

Share the Love

Like this project? Please give it a ★ on our GitHub! (it helps us a lot)

Are you using this project or any of our other projects? Consider leaving a testimonial. =)

Related Projects

Check out these related projects.

References

For additional context, refer to some of these links.

  • github-actions-workflows - Reusable workflows for different types of projects
  • geodesic - It’s a swiss army knife for creating and building consistent platforms to be shared across a team environment

Help

Got a question? We got answers.

File a GitHub issue, send us an email or join our Slack Community.

README Commercial Support

DevOps Accelerator for Startups

We are a DevOps Accelerator. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us.

Learn More

Work directly with our team of DevOps experts via email, slack, and video conferencing.

We deliver 10x the value for a fraction of the cost of a full-time engineer. Our track record is not even funny. If you want things done right and you need it done FAST, then we're your best bet.

  • Reference Architecture. You'll get everything you need from the ground up built using 100% infrastructure as code.
  • Release Engineering. You'll have end-to-end CI/CD with unlimited staging environments.
  • Site Reliability Engineering. You'll have total visibility into your apps and microservices.
  • Security Baseline. You'll have built-in governance with accountability and audit logs for all changes.
  • GitOps. You'll be able to operate your infrastructure via Pull Requests.
  • Training. You'll receive hands-on training so your team can operate what we build.
  • Questions. You'll have a direct line of communication between our teams via a Shared Slack channel.
  • Troubleshooting. You'll get help to triage when things aren't working.
  • Code Reviews. You'll receive constructive feedback on Pull Requests.
  • Bug Fixes. We'll rapidly work with you to fix any bugs in our projects.

Slack Community

Join our Open Source Community on Slack. It's FREE for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally sweet infrastructure.

Discourse Forums

Participate in our Discourse Forums. Here you'll find answers to commonly asked questions. Most questions will be related to the enormous number of projects we support on our GitHub. Come here to collaborate on answers, find solutions, and get ideas about the products and services we value. It only takes a minute to get started! Just sign in with SSO using your GitHub account.

Newsletter

Sign up for our newsletter that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover.

Office Hours

Join us every Wednesday via Zoom for our weekly "Lunch & Learn" sessions. It's FREE for everyone!

zoom

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Developing

If you are interested in being a contributor and want to get involved in developing this project or help out with our other projects, we would love to hear from you! Shoot us an email.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Pull Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

Copyright

Copyright © 2017-2022 Cloud Posse, LLC

License

License

See LICENSE for full details.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.

Trademarks

All other trademarks referenced herein are the property of their respective owners.

About

This project is maintained and funded by Cloud Posse, LLC. Like it? Please let us know by leaving a testimonial!

Cloud Posse

We're a DevOps Professional Services company based in Los Angeles, CA. We ❤️ Open Source Software.

We offer paid support on all of our projects.

Check out our other projects, follow us on twitter, apply for a job, or hire us to help with your cloud strategy and implementation.

Contributors

Igor Rodionov
Igor Rodionov

README Footer Beacon