I am trying to create a VPC endpoint using aws-java-sdk "com.amazonaws.services.ec2.model.CreateVpcEndpointRequest" API. This fails with the below issue. This is being created in a private subnet.
error": "com.amazonaws.services.ec2.model.AmazonEC2Exception: The Vpc Endpoint Service 'com.amazonaws.vpce.us-west-2.vpce-svc-***' does not exist (Service: AmazonEC2; Status Code: 400; Error Code: InvalidServiceName; Request ID: ***; Proxy: null)"
The VPCE-svc is added with the allowed principal and configured to accept the connection requests automatically.
Please note that we are able to create the VPC endpoint against the same vpce-svc manually. The code works fine, able to successfully create vpc endpoints for different accounts/vpc-svc/vpc/subnet. The issue is limited to one setup
Any pointer to debug this is greatly appreciated. thanks in advance
Update: code snippet
createVpcEndpointRequest request = new CreateVpcEndpointRequest()
.withPrivateDnsEnabled(privateDns)
.withSecurityGroupIds(Collections.singleton(securityGroupId))
// VPCE Service
.withVpcEndpointType(VpcEndpointType.Interface.toString())
.withServiceName(privatelinkServiceName)
// Network
.withVpcId(vpcId)
.withSubnetIds(subnetIds);
createVpcEndpointResult = ec2Client.createVpcEndpoint(request);