aws / aws/aws-cdk

aws-ecs: CloudMap service name is unexpectedly a token

Open
#22,320 2 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-ecs bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

CloudMap service name is unexpectedly a token in `EC2Service`.

### Reproduction Steps

1) Build `Ec2Service` and provide `cloudMapOptions` `name`.
1) Later get `name` back from the built service via `getCloudMapService` -> `getServiceName`.

In Clojure:

```clj
(let [service (-> (Ec2Service$Builder/create ...)
(.cloudMapOptions (-> (CloudMapOptions$Builder.)
(.cloudMapNamespace ...)
(.name "foobar")
.build))
...
.build)]
(println (.getServiceName (.getCloudMapService service))))
```

### Expected Behavior

Prints `foobar`.

### Current Behavior

Prints something like `${Token[TOKEN.14258]}`.

### Additional Information/Context

I need `name` to construct the service discovery endpoint URL for the service:

```clj
(defn sd-http-url
[service port]
(let [cloud-map-service (.getCloudMapService service)]
(str "http://"
(.getServiceName cloud-map-service)
"."
(.getNamespaceName (.getNamespace cloud-map-service))
":"
port)))
```

Such URL is used outside of CDK deployment, so it should not contain any tokens.

Maybe there's some better way to achieve the same result?

At the moment I need to invent some workaround based on getting `name` via a CloudFormation output or just manually pass it around with the `service` value.

### CDK CLI Version

2.42.1

### Framework Version

2.42.1

### Node.js Version

16.8.0

### OS

macOS

### Language

Java

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue through Ec2Service, CloudMapOptions, getCloudMapService, and getServiceName using the provided example. Inspect how the supplied CloudMap service name is represented after building the service, and compare the returned value with the expected concrete name; done means the documented access path has clear, verified behavior for this use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.