I have two VPCs(VPC_A, VPC_B) in two different accounts (AccountA, AccountB) and both VPCs are peered successfully. I have CDK code that has a pipeline stage to deploy to AccountA. I have a need to lookup VPC_B from AccountA's context and lookup & modify security group which is in VPC_B. I have below code written, but it's not working. When I do cdk synth, it gives me an error saying it cannot find VPC_B in AccountA's context.
const vpcB: IVpc = ec2.Vpc.fromLookup(this, 'VPC_B', {
vpcId: 'VPC_B_ID'
});
const SG_B: ISecurityGroup = ec2.SecurityGroup.fromLookupByName(
this,
'SG-B',
'SG-B_ID,
vpcB
);
Here is the synth step in CodePipeline
synthCodeBuildDefaults: {
rolePolicy: [
new PolicyStatement({
actions: ["sts:AssumeRole"],
effect: Effect.ALLOW,
resources: [
'lookup_role_arn_for_account_a
],
}),
]
}
Any help is appreciated