AWS Cloud Map Specialized2018年〜
A service discovery service for application resources
What It Does
AWS Cloud Map is a service discovery service that centrally manages the locations (IP addresses, URLs, etc.) of services and resources that make up your application, making them searchable by name. In microservices architectures, it enables each service to dynamically discover the connection endpoints of other services. It supports both DNS-based and API-based discovery methods.
Use Cases
Cloud Map is used in microservices architectures to dynamically resolve communication endpoints between services. For example, when containers on ECS or EKS scale up or down, connection information is automatically updated so other services always get the correct endpoints. It is also used as a unified service registry that includes non-container resources like Lambda functions and databases.
Everyday Analogy
Think of it like a company phone directory. In a large company, employees transfer between departments and new departments are created. Cloud Map is a phone directory that's always kept up to date - search for "Tanaka in Sales" and you instantly get their current extension number (IP address). Even when employees change desks, the directory updates automatically, so you never call an outdated number.
What Is Cloud Map?
AWS Cloud Map is a service discovery service for managing and searching cloud application resources by name. In microservices, many small services communicate with each other, but each service's connection details (IP addresses and port numbers) change with every scaling event or deployment. Cloud Map centrally manages this connection information and returns the latest endpoints when queried by service name.
DNS-Based and API-Based Discovery
Cloud Map provides two discovery methods. DNS-based discovery registers service names as DNS names and resolves endpoints through standard DNS queries. This has the advantage of being adoptable without modifying existing applications. API-based discovery uses the AWS SDK to retrieve endpoints. It can return not just IP addresses but also port numbers and custom attributes (such as version information), enabling more flexible routing.
Integration with ECS and EKS
Cloud Map integrates with Amazon ECS and Amazon EKS, automatically registering and deregistering service instances during container deployments. For example, when an ECS service scales out from 3 to 5 tasks, the IP addresses of the 2 new tasks are automatically registered in Cloud Map. When tasks stop, they are automatically deregistered, requiring no manual maintenance. For practical knowledge on integrating with ECS and EKS, books (Amazon) are helpful.
Getting Started
To get started with Cloud Map, first create a namespace. You can choose between DNS-based or API-based namespaces. Next, create a service within the namespace and register service instances (the actual connection information for your resources). If you're using ECS, simply enable Cloud Map integration in your service definition to automate task registration and deregistration.
Things to Watch Out For
- DNS-based discovery depends on DNS cache TTL, so endpoint changes may not be reflected immediately. Consider API-based discovery when real-time resolution is needed.
- Enabling Cloud Map's health check feature automatically excludes unhealthy instances from discovery results.
- The namespace type (DNS public, DNS private, API only) cannot be changed after creation, so choose the right type for your use case in advance.