ฉันมี ARN ของ downstream องทรัพยากรของเว็บเบราว์เซอร์ภายนอก AWS บัญชี ของฉันแปรหัสอยู่ใน AWS CDK. อยู่ในรหัสของฉันฉันจะทำการคลายแฟ้มไปไว้ที่ accountId จาก ARN. ยังไงฉันต้องทำอย่างนั้น?
0
มันจะเป็น elegantly ทำโดยใช้ขั้ 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