File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,16 @@ readonly BOOKMARK_DIR="${PGWEB_BASE}/bookmarks"
1111# Create base directory if it doesn't exist
1212mkdir -p " ${PGWEB_BASE} "
1313
14+ # Helper function to get AWS region
15+ get_region () {
16+ local imds_token
17+ imds_token=" $( wget --method=PUT --header " X-aws-ec2-metadata-token-ttl-seconds:600" -q -O - http://169.254.169.254/latest/api/token) "
18+ local region
19+ region=" $( wget --header " X-aws-ec2-metadata-token: ${imds_token} " -q -O - http://169.254.169.254/latest/meta-data/placement/region) "
20+
21+ echo " ${region} "
22+ }
23+
1424# Helper function to get credentials and generate IAM auth token
1525generate_iam_token () {
1626 local resource_id=" ${1} "
@@ -76,6 +86,10 @@ refresh_bookmarks() {
7686 RESOURCES=$( ${WB_EXE} resource list --format json)
7787 readonly RESOURCES
7888
89+ local VM_REGION
90+ VM_REGION=$( get_region)
91+ readonly VM_REGION
92+
7993 # Process each resource
8094 echo " ${RESOURCES} " | jq -c ' .[]' | while read -r resource; do
8195 local RESOURCE_TYPE
@@ -119,6 +133,12 @@ refresh_bookmarks() {
119133 continue
120134 fi
121135
136+ if [[ " ${REGION} " != " ${VM_REGION} " ]]; then
137+ echo " Resource region (${REGION} ) does not match VM region (${VM_REGION} ), skipping"
138+ touch " ${TEMP_DIR} /${RESOURCE_ID} (Disabled - Cross Region).toml"
139+ continue
140+ fi
141+
122142 # Try to create READ_ONLY bookmark
123143 echo " Checking read access..."
124144 local RO_TOKEN
You can’t perform that action at this time.
0 commit comments