aws / aws/aws-cdk

(Tags): Tagging a VPC Interface Endpoint applies the tag on the VPCe Security Group instead of a tag on VPCe

Open
#19,332 10 comments 5 reactions 0 assignees View on GitHub
@aws-cdk/aws-ec2 blocked bug needs-cfn p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
71

Description

### What is the problem?

Team,
When applying a tag on a VPC Interface Endpoint, the tag gets applied to the Security Group instead of the VPC Endpoint itself.

Code:
```typescript
const vpceEC2 = vpc.addInterfaceEndpoint('vpce-ec2', {
service: ec2.InterfaceVpcEndpointAwsService.EC2,
lookupSupportedAzs: true,
open: true,
privateDnsEnabled: true,
subnets: { subnetType: ec2.SubnetType.PRIVATE_ISOLATED }
});
Tags.of(vpceEC2).add('Name', `myVPCeEC2`);
```

I did a search in Resource Groups Management and the result is as follows:
![Screen Shot 2022-03-10 at 1 41 31 PM](https://user-images.githubusercontent.com/78559652/157732601-c0ac51d0-e301-47b5-8912-66d1dd804e92.png)

### Reproduction Steps

Start a new project using cdk init and using lib `"aws-cdk-lib": "2.15.0"`

Add the following code to your stack
Code:
```typescript
const vpcName = "my-cdk-vpc";
const vpc = new ec2.Vpc(this, vpcName, {
cidr: '10.0.0.0/16',
natGateways: 0,
defaultInstanceTenancy: DefaultInstanceTenancy.DEFAULT,
enableDnsHostnames: buildConfig.enableDnsHostnames,
enableDnsSupport: buildConfig.enableDnsSupport,
maxAzs: buildConfig.vpcMaxAZs,
subnetConfiguration: [
{
name: 'private-isolated-',
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
cidrMask: 24,
}
],
});
const vpceEC2 = vpc.addInterfaceEndpoint('vpce-ec2', {
service: ec2.InterfaceVpcEndpointAwsService.EC2,
lookupSupportedAzs: true,
open: true,
privateDnsEnabled: true,
subnets: { subnetType: ec2.SubnetType.PRIVATE_ISOLATED }
});
Tags.of(vpceEC2).add('Name', `myVPCeEC2`);
```

### What did you expect to happen?

I expected that the VPC Interface Endpoint to have the tag applied to it.

### What actually happened?

The tag was applied to its security group instead.

### CDK CLI Version

2.15.0 (build 151055e)

### Framework Version

v2

### Node.js Version

v14.15.4

### OS

macOS

### Language

Typescript

### Language Version

3.9.7

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the vpc.addInterfaceEndpoint entry point and reproduce the reported Tags.of(vpceEC2).add call from the issue. Trace which resource receives the tag, then verify that the tag is applied to the VPC Interface Endpoint rather than its security group.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.