From 45d7c499f394c7dcbcd35821789607d31f42700d Mon Sep 17 00:00:00 2001 From: Vignir Hafsteinsson Date: Thu, 29 Apr 2021 14:27:56 +0000 Subject: [PATCH] Updating ARN regex to handle non-standard regions Changing the regex scrip to handle the ARN format in non-standard AWS regions. The ARN format used in AWS China and GovCloud is different than in other regions. --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 733c03c..9d2b14b 100644 --- a/main.go +++ b/main.go @@ -23,7 +23,7 @@ import ( var ( configFilePath = fmt.Sprintf("%s/.aws/roles", os.Getenv("HOME")) - roleArnRe = regexp.MustCompile(`^arn:aws:iam::(.+):role/([^/]+)(/.+)?$`) + roleArnRe = regexp.MustCompile(`^arn:aws(-((cn)|(us-gov)))?:iam::(.+):role/([^/]+)(/.+)?$`) ) func usage() {