Skip to content
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

Add 'iam' prefix to 'serviceAccount' export #2965

Closed
1 task
strongishllama opened this issue Jun 25, 2023 · 2 comments
Closed
1 task

Add 'iam' prefix to 'serviceAccount' export #2965

strongishllama opened this issue Jun 25, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@strongishllama
Copy link

strongishllama commented Jun 25, 2023

Description

Hi there 👋

Currently, as the serviceAccount export doesn't have the service prefix like all the other exports, the following construct cannot be built by jsii and fails with following error.

I've tried several workarounds, such as:

  • Using an as import like so: import { serviceAccount as iamServiceAccount } from "@cdktf/provider-google";
  • Creating a BaseServiceAccount class that creates the serviceAccount resource, and then extending it with a ServiceAccount subclass.

None of the above have worked.

I understand that the provider resources are generated, but would there be a way to add an override for the serviceAccount export, so it becomes iamServiceAccount? This would have two main benefits:

  • Keeping a consistent naming conversion of ServiceName-ResourceName
  • Allow for a cleaner looking interface when being able to use ServiceAccount as a class/construct name.
import { Construct } from "constructs";
import { serviceAccount } from "@cdktf/provider-google";

export interface ServiceAccountConfig {
  readonly accountId: string;
}

export class ServiceAccount extends Construct {
  public readonly grantMember: string;

  private readonly resource: serviceAccount.ServiceAccount;

  constructor(scope: Construct, id: string, config: ServiceAccountConfig) {
    super(scope, id);

    this.resource = new serviceAccount.ServiceAccount(this, "resource", {
      accountId: config.accountId,
    });

    this.grantMember = this.resource.member;
  }
}
service-account/service-account.ts:6:14 - error JSII5011: Submodule "serviceAccount" conflicts with "ServiceAccount, as different languages could represent it as: "serviceAccount", "ServiceAccount", "service_account""

6 export class ServiceAccount extends BaseServiceAccount {
               ~~~~~~~~~~~~~~

  ../../../node_modules/@cdktf/provider-google/lib/index.d.ts:584:13
    584 export * as serviceAccount from './service-account';
                    ~~~~~~~~~~~~~~
    This is the conflicting submodule declaration

Thanks in advance! 🙏

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@strongishllama strongishllama added enhancement New feature or request new Un-triaged issue labels Jun 25, 2023
@DanielMSchmidt
Copy link
Contributor

We follow the Terraform resource schema very closely to be predictable and avoid confusion. I am afraid you will need to find another name for the ServiceAccount in your local construct or do some workaround yourself (you could probably use a locally built provider and have a bash script replace the export * as ... statement if it's that important to you).

@DanielMSchmidt DanielMSchmidt removed the new Un-triaged issue label Jul 14, 2023
@github-actions
Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants