Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(ec2): Get ARN for VPC #16493

Closed
1 of 2 tasks
chelproc opened this issue Sep 15, 2021 · 2 comments · Fixed by #16666
Closed
1 of 2 tasks

(ec2): Get ARN for VPC #16493

chelproc opened this issue Sep 15, 2021 · 2 comments · Fixed by #16666
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2

Comments

@chelproc
Copy link

chelproc commented Sep 15, 2021

Use Case

PolicyStatement

const role = new Role(this, 'AcceptVpcPeeringRole', {
  assumedBy: new AccountPrincipal('********'),
});
const vpcArn = `arn:aws:ec2:${vpc.env.region}:${vpc.env.account}:vpc/${vpc.vpcId}`;
role.addToPolicy(
  new PolicyStatement({
    resources: [vpcArn],
    actions: ['ec2:AcceptVpcPeeringConnection'],
  }),
);
role.addToPolicy(
  new PolicyStatement({
    resources: ['*'],
    conditions: { StringEquals: { 'ec2:AccepterVpc': vpcArn } },
    actions: ['ec2:AcceptVpcPeeringConnection'],
  }),
);

Proposed Solution

Add vpcArn property for Vpc construct.

const vpc = new Vpc(self, 'Vpc');
// `arn:aws:ec2:${vpc.env.region}:${vpc.env.account}:vpc/${vpc.vpcId}`
vpc.vpcArn;

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@chelproc chelproc added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Sep 15, 2021
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Sep 15, 2021
@chelproc chelproc changed the title (vpc): Get ARN for VPC (ec2): Get ARN for VPC Sep 15, 2021
@njlynch njlynch added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Sep 21, 2021
@njlynch
Copy link
Contributor

njlynch commented Sep 21, 2021

Thanks for this feature request. I can certainly see the use case, and it would be simple enough to add.

As an implementation note, using Arn.format would auto-detect several of those components and make it a bit easier, including handling partitions (which often is forgotten about).

We welcome community contributions! If you are able, we encourage you to contribute.

@njlynch njlynch removed their assignment Sep 21, 2021
@njlynch njlynch added the good first issue Related to contributions. See CONTRIBUTING.md label Sep 21, 2021
@mergify mergify bot closed this as completed in #16666 Oct 25, 2021
mergify bot pushed a commit that referenced this issue Oct 25, 2021
fixes #16493

introduces context aware ARN for VPC, dervied from the current stack.
This allows easier referencing compared to constructing the ARN from the vpc id.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
fixes aws#16493

introduces context aware ARN for VPC, dervied from the current stack.
This allows easier referencing compared to constructing the ARN from the vpc id.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants