hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.61k stars 9k forks source link

[New Data Source]: aws_opensearchserverless_vpc_endpoints check if vpc_endpoint exists for a specific VPC id #37741

Open wesleung opened 1 month ago

wesleung commented 1 month ago

Description

Basic issue is that only one VPC endpoint can exists per VPC. In my case I have multiple collections in one VPC and the terraform code should detect if a vpc_endpoint already exists and configure to use it.

Data Source: aws_opensearchserverless_vpc_endpoints check if vpc_endpoint exists for a specific VPC id or returns all vpc _endpoints if no vpc_id is passed in as the input attribute

Affected Resource(s) and/or Data Source(s)

Related to aws_opensearchserverless_vpc_endpoint

Potential Terraform Configuration

# Returns all VPC endpoints
data "aws_opensearchserverless_vpc_endpoints" "example" {
}
# Returns one endpoint for a specific VPC id
data "aws_opensearchserverless_vpc_endpoints" "example" {
  vpc_id = "vpc-############"
}

References

terraform code would need to run something like the below AWS cli commands and then optionally filter for the specific vpcId

aws opensearchserverless batch-get-vpc-endpoint --ids $(aws opensearchserverless list-vpc-endpoints --query vpcEndpointSummaries[].id --output text)

Would you like to implement a fix?

None

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue