pulumi / pulumi/pulumi-java

Importing a resource with `.` in the name converts it to `_` but it gets saved with `.` in the stack

Open
#1,605 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/codegen kind/bug language/java
Dominant language
Java
Stars
85
Forks
26
Avg merge
11h 49m
Merged PRs (30d)
22

Description

What happened?

I imported a kafka topic into my stack. The name of the resource has full stops in i.e. organizations_db.public.teams. Pulumi instructed me to declare the resource with the full stops replaced by underscores i.e. organizations_db_public_teams. However, it saved it in the stack as organizations_db.public.teams.

Example

pulumi import kafka:index/topic:Topic organizations_db.public.teams organizations_db.public.teams --yes
outputted

public static void stack(Context ctx) {
    var organizations_db_public_teams = new Topic("organizations_db_public_teams", TopicArgs.builder()
      .config(Map.of("cleanup.policy", "delete"))
      .name("organizations_db.public.teams")
      .partitions(6)
      .replicationFactor(3)
      .build(), CustomResourceOptions.builder()
        .protect(true)
        .build());

}

but the stack state showed:

├─ kafka:index/topic:Topic                    organizations_db.public.teams
    │     URN: urn:pulumi:prod::cluster::kafka:index/topic:Topic::organizations_db.public.teams
Output of pulumi about
CLI          
Version      3.144.0
Go Version   go1.23.4
Go Compiler  gc

Plugins
KIND      NAME  VERSION
language  java  0.19.0

Host     
OS       debian
Version  12.8
Arch     aarch64

This project is written in java: executable='/usr/bin/java' version='openjdk 21.0.5 2024-10-15 LTS
OpenJDK Runtime Environment Microsoft-10376803 (build 21.0.5+11-LTS)
OpenJDK 64-Bit Server VM Microsoft-10376803 (build 21.0.5+11-LTS, mixed mode, sharing)' java='/usr/bin/java' javac='21.0.5' maven='Apache Maven 3.8.7' gradle='4.4.1'
Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided pulumi import kafka:index/topic:Topic command and compare the generated Java declaration with the resulting stack URN. Trace the import and naming path responsible for converting periods to underscores, then verify that the declared resource name and saved stack identity remain consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kafka
Domain
developer-experience, tooling
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.