|
| 1 | +--- |
| 2 | +type: docs |
| 3 | +title: "AWS Cloudmap" |
| 4 | +linkTitle: "AWS Cloudmap" |
| 5 | +description: Detailed information on the AWS Cloudmap name resolution component |
| 6 | +--- |
| 7 | + |
| 8 | + |
| 9 | +This component uses [AWS Cloud Map](https://aws.amazon.com/cloud-map/) for service discovery in Dapr. It supports both HTTP and DNS namespaces, allowing services to discover and connect to other services using AWS Cloud Map's service discovery capabilities. |
| 10 | + |
| 11 | +## Configuration format |
| 12 | + |
| 13 | +Name resolution is configured via the [Dapr Configuration]({{< ref configuration-overview.md >}}). |
| 14 | + |
| 15 | +Within the configuration YAML, set the `spec.nameResolution.component` property to `"aws.cloudmap"`, then pass configuration options in the `spec.nameResolution.configuration` dictionary. |
| 16 | + |
| 17 | +```yaml |
| 18 | +apiVersion: dapr.io/v1alpha1 |
| 19 | +kind: Configuration |
| 20 | +metadata: |
| 21 | + name: appconfig |
| 22 | +spec: |
| 23 | + nameResolution: |
| 24 | + component: "aws.cloudmap" |
| 25 | + version: "v1" |
| 26 | + configuration: |
| 27 | + # Required: AWS CloudMap namespace configuration (one of these is required) |
| 28 | + namespaceName: "my-namespace" # The name of your CloudMap namespace |
| 29 | + # namespaceId: "ns-xxxxxx" # Alternative: Use namespace ID instead of name |
| 30 | + |
| 31 | + # Optional: AWS authentication (choose one authentication method) |
| 32 | + # Option 1: Environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY |
| 33 | + # Option 2: IAM roles for Amazon EKS |
| 34 | + # Option 3: Explicit credentials (not recommended for production) |
| 35 | + accessKey: "****" |
| 36 | + secretKey: "****" |
| 37 | + sessionToken: "****" # Optional |
| 38 | + |
| 39 | + # Optional: AWS region and endpoint configuration |
| 40 | + region: "us-west-2" |
| 41 | + endpoint: "http://localhost:4566" # Optional: Custom endpoint for testing |
| 42 | + |
| 43 | + # Optional: Dapr configuration |
| 44 | + defaultDaprPort: 50002 # Default port for Dapr sidecar if not specified in instance attributes |
| 45 | +``` |
| 46 | +
|
| 47 | +## Specification |
| 48 | +
|
| 49 | +### AWS authentication |
| 50 | +
|
| 51 | +The component supports multiple authentication methods: |
| 52 | +
|
| 53 | +1. Environment Variables: |
| 54 | + - AWS_ACCESS_KEY_ID |
| 55 | + - AWS_SECRET_ACCESS_KEY |
| 56 | + - AWS_SESSION_TOKEN (optional) |
| 57 | +
|
| 58 | +2. IAM Roles: |
| 59 | + - When running on AWS (EKS, EC2, etc.), the component can use IAM roles |
| 60 | +
|
| 61 | +3. Explicit Credentials: |
| 62 | + - Provided in the component metadata (not recommended for production) |
| 63 | +
|
| 64 | +### Required permissions |
| 65 | +
|
| 66 | +The AWS credentials must have the following permissions: |
| 67 | +```json |
| 68 | +{ |
| 69 | + "Version": "2012-10-17", |
| 70 | + "Statement": [ |
| 71 | + { |
| 72 | + "Effect": "Allow", |
| 73 | + "Action": [ |
| 74 | + "servicediscovery:DiscoverInstances", |
| 75 | + "servicediscovery:GetNamespace", |
| 76 | + "servicediscovery:ListNamespaces" |
| 77 | + ], |
| 78 | + "Resource": "*" |
| 79 | + } |
| 80 | + ] |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +### Spec configuration fields |
| 85 | + |
| 86 | +| Field | Required | Type | Default | Description | |
| 87 | +|-----------------|-------------------------------------|--------|---------|-------------| |
| 88 | +| namespaceName | One of namespaceName or namespaceId | string | "" | The name of your AWS CloudMap namespace | |
| 89 | +| namespaceId | One of namespaceName or namespaceId | string | "" | The ID of your AWS CloudMap namespace | |
| 90 | +| region | N | string | "" | AWS region. If not provided, will be determined from environment or instance metadata | |
| 91 | +| endpoint | N | string | "" | Custom endpoint for AWS CloudMap API. Useful for testing with LocalStack | |
| 92 | +| defaultDaprPort | N | number | 3500 | Default port for Dapr sidecar if not specified in instance attributes | |
| 93 | + |
| 94 | +### Service registration |
| 95 | + |
| 96 | +To use this name resolver, your services must be registered in AWS CloudMap. When registering instances, ensure they have the following attributes: |
| 97 | + |
| 98 | +1. Required: One of these address attributes: |
| 99 | + - `AWS_INSTANCE_IPV4`: IPv4 address of the instance |
| 100 | + - `AWS_INSTANCE_IPV6`: IPv6 address of the instance |
| 101 | + - `AWS_INSTANCE_CNAME`: Hostname of the instance |
| 102 | + |
| 103 | +2. Optional: Dapr sidecar port attribute: |
| 104 | + - `DAPR_PORT`: The port that the Dapr sidecar is listening on |
| 105 | + - If not specified, the component will use the `defaultDaprPort` from configuration (defaults to 3500) |
| 106 | + |
| 107 | +The resolver only returns healthy instances (those with `HEALTHY` status) to ensure reliable service communication. |
| 108 | + |
| 109 | +Example instance attributes: |
| 110 | +```json |
| 111 | +{ |
| 112 | + "AWS_INSTANCE_IPV4": "10.0.0.1", |
| 113 | + "DAPR_PORT": "50002" |
| 114 | +} |
| 115 | +``` |
| 116 | + |
| 117 | + |
| 118 | +## Example Usage |
| 119 | + |
| 120 | +Name resolution is configured via the [Dapr Configuration]({{< ref configuration-overview.md >}}). Here are some examples of its usage. |
| 121 | + |
| 122 | +### Minimal Configuration |
| 123 | + |
| 124 | +```yaml |
| 125 | +apiVersion: dapr.io/v1alpha1 |
| 126 | +kind: Configuration |
| 127 | +metadata: |
| 128 | + name: appconfig |
| 129 | +spec: |
| 130 | + nameResolution: |
| 131 | + component: "aws.cloudmap" |
| 132 | + configuration: |
| 133 | + namespaceName: "mynamespace.dev" |
| 134 | + defaultDaprPort: 50002 |
| 135 | +``` |
| 136 | +
|
| 137 | +### Local Development with LocalStack |
| 138 | +
|
| 139 | +```yaml |
| 140 | +apiVersion: dapr.io/v1alpha1 |
| 141 | +kind: Configuration |
| 142 | +metadata: |
| 143 | + name: appconfig |
| 144 | +spec: |
| 145 | + nameResolution: |
| 146 | + component: "aws.cloudmap" |
| 147 | + configuration: |
| 148 | + namespaceName: "my-namespace" |
| 149 | + region: "us-east-1" |
| 150 | + endpoint: "http://localhost:4566" |
| 151 | + accessKey: "test" |
| 152 | + secretKey: "test" |
| 153 | +``` |
| 154 | +
|
| 155 | +### Related Links |
| 156 | +- [Service invocation building block]({{< ref service-invocation >}}) |
| 157 | +- [AWS Cloudmap documentation](https://aws.amazon.com/cloud-map/) |
0 commit comments