我有ARN的下游资源的外部证书。 我的基础设施代码。CDK。 在我的代码,我想提取accountId从ARN。 我要怎么做?
0
它可以是优雅地使用核心cdk图书馆。 这里的方案:
import { Arn } from 'monocdk';
import arn = require("monocdk/lib/core/lib/arn");
private static getAccountIdFromArn(arn: string): string {
const arnComponents = Arn.parse(arn)
if(undefined === arnComponents.account) {
throw new Error(`account id not present in the arn @{arn}!`)
}
return arnComponents.account
}
接受的答案,如果它解决你的问题。
gshpychka