aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap

Allow ENIs to be specified when creating a VPC Endpoint

Open
#1,254 4 comments 4 reactions 0 assignees View on GitHub
enhancement
Dominant language
No language data
Stars
1.1k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

### Name of the resource

AWS::EC2::VPCEndpoint

### Resource name

_No response_

### Description

**My use case**
As part of my stack I need to create a target group for a VpcE. To create the target group I need the IPs from the VpcE's ENIs. CloudFormation does not currently provide an option to specify the ENIs when creating a VpcE, instead they are provisioned automatically. This means that you do not have a handle on the IPs you need [1].

**Feature request**
Add a new `NetworkInterfaceIds` attribute to `AWS::EC2::VPCEndpoint`. This could be used as an alternative to `SubnetIds` for creating the ENIs. This would allow manually defined ENIs to be used to create both the VpcE and the Target Group.

**Workaround**
My current workaround involves creating the VpcE, then calling describe-network-interfaces [2] for each ENI via a custom resource. See CDK code in Other Details.

[1] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-networkinterface.html#aws-resource-ec2-networkinterface-return-values

[2] https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-network-interfaces.html

### Other Details

```
private createVpceTargetGroup(vpce: ec2.InterfaceVpcEndpoint): elbv2.NetworkTargetGroup {
const targetGroup = new elbv2.NetworkTargetGroup(this, 'VpcE-Targets', {
vpc: this.vpc,
port: 443,
targetGroupName: `${vpce.vpcEndpointId}-Targets`
})

for (let index = 0; index < this.vpc.availabilityZones.length; index++) {
const getEndpointIp = new cr.AwsCustomResource(this, `GetEndpointIp${index}`, {
onUpdate: {
service: 'EC2',
action: 'describeNetworkInterfaces',
outputPaths: [`NetworkInterfaces.${index}.PrivateIpAddress`],
parameters: { NetworkInterfaceIds: vpce.vpcEndpointNetworkInterfaceIds },
physicalResourceId: cr.PhysicalResourceId.of(`NetworkInterfaces.${index}.PrivateIpAddress`)
},
policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE
})
});
targetGroup.addTarget(new elbv2_targets.IpTarget(Token.asString(getEndpointIp.getResponseField(`NetworkInterfaces.${index}.PrivateIpAddress`))))
}

return targetGroup
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the AWS::EC2::VPCEndpoint resource and its current SubnetIds behavior, then compare the requested NetworkInterfaceIds alternative with the EC2 endpoint and network-interface documentation linked in the issue. Done means the resource can use manually defined ENIs and the resulting endpoint supports the target-group use case without the custom-resource workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.