Skip to content

aws_ec2: ARN for shared VPC has wrong account id #23865

@hugowschneider

Description

@hugowschneider

Describe the bug

When looking up for a shared VPC with:

vpc =  ec2.Vpc.from_lookup(self, "VPC", vpc_id=shared_vpc_id)

and then reading the vpc_arn

print(vpc.vpc_arn)

Instead of having the correct ARN like arn:aws:ec2:eu-west-1:YYYYYYYY:vpc/vpc-1234567890 where YYYYYY should be the account owning the VPC, I get arn:aws:ec2:eu-west-1:XXXXXXXX:vpc/vpc-1234567890, where XXXXX is the account where I am trying to deploy my stack.

Expected Behavior

I would expect that the attrivute vpc_arn would return the correct VPC ARN referring to the owning account.

Current Behavior

The stack refers to a wrong ARN.

Reproduction Steps

  • Share a VPC from account Y to account X
  • In account X try to deploy a CDK stack where
    • This VPC is retrieve with ec2.Vpc.from_lookup(self, "VPC", vpc_id=shared_vpc_id)
    • Add a iam role policy where the resource is vpc.vpc_arn

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.61.1 (build d319d9c)

Framework Version

No response

Node.js Version

v16.17.0

OS

MacOS

Language

Python

Language Version

Python 3.9.13

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ec2Related to Amazon Elastic Compute CloudbugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions