我正在尝试从AWS ARN(Amazon资源编号)中提取Postgres RDS实例的账户名称和区域,并将其传递给另一个脚本。例如,对于ARN:
region= eu-central-1
在上面的示例中,我尝试提取accountnumber= 123456789777
和pytest --cov sample test.py
答案 0 :(得分:2)
我们可以在此处尝试使用SPLIT_PART
with cte AS (
select 'arn:aws:rds:eu-central-1:123456789777:db:testdb'::text as arn
)
select
split_part(arn, ':', 4) as region,
split_part(arn, ':', 5) as account_no
from cte;