Skip to content

Improve mapping of resources & datasources #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ringods
Copy link

@ringods ringods commented Apr 30, 2025

Hello, Ringo here from Pulumi 👋🏻

You reached out via our support system regarding the incorrect naming of mapped datasources. When looking into your provider, I noticed you were not mapping types as it is usually done in Pulumi:

  • resources are mapped to classes starting with a capital, e.g. volcengine_cloud_identity_group -> volcengine.cloud_identity.Group
  • datasources are mapped to functions starting with get...: volcengine_cloud_identity_users -> volcengine.cloud_identity.getUsers

Until now, you also mapped the datasources to type closely resembling the resources pattern. This PR gives an example how it should be.

In this PR, I also applied a newer feature from the Terraform bridge called auto-mapping. Using tks.MappedModules, resources and datasources which follow part of the name, will be mapped to the correct corresponding Pulumi resource types or functions. However, if you still provide a custom mapping under Resources or DataSources in provider/resources.go, then that will take precedence.

Since function names changed, I made sure that auto-aliasing is active. This will result in new files getting generated in the SDKs for the correct names, with deprecations for the old names.

If, in the future, you want to bump from v0 to v1 of your provider, right before versioning the v1, replace the content of provider/cmd/pulumi-resource-volcengine/bridge-metadata.json with {}, save and then rebuild everything with make clean provider build_sdks. This will remove all the deprecated types and give you a clean SDK again.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant