Sets up an HTTP namespace, a service discovery service, and a service discovery instance with EC2 instance ID attribute.

Terraform Template

resource "aws_service_discovery_http_namespace" "example" {
  description = "example"
  name = "example.terraform.com"
}

resource "aws_service_discovery_instance" "example" {

  attributes = {
    AWS_EC2_INSTANCE_ID = "i-0abdg374kd892cj6dl"
  }
  instance_id = "example-instance-id"
  service_id = aws_service_discovery_service.example.id
}

resource "aws_service_discovery_service" "example" {
  name = "example"
  namespace_id = aws_service_discovery_http_namespace.example.id
}