question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to generate module binding when alias providers are used

See original GitHub issue

@jsteinich Thank you for pointing me to the other post.

I think my issue is with cdktf.json file which expects me to list the provider for aws.alternate.

I am using the pre-built provider for AWS and therefore do not list any providers in the cdktf.json. I only specify the modules that I am using which are privately hosted. Here is my cdktf.json:

{
  "language": "python",
  "app": "python ./main.py",
  "output": "cdktf.out",
  "terraformModules": [
    "git::<git-repo>"
  ],
  "codeMakerOutput": "imports",
  "context": {
    "excludeStackIdFromLogicalIds": "true",
    "allowSepCharsInLogicalIds": "true"
  },
  "projectId": "REDACTED"
}

So I keep getting the error below when running cdktf get:There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
╷
│ Error: No configuration for provider aws.alternate
│ 
│   on main.tf.json line 1, in module:
│    1: {"terraform":{},"module":{"<my_module>":{"source":"git::<git-repo>}}}
│ 
│ Configuration required for
│ module.<my_module>.provider["registry.terraform.io/hashicorp/aws"].alternate.
│ Add a provider named aws.alternate to the providers map for
│ module.<my_module>
│ in the root module.
╵
Error: non-zero exit code 1
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/util.js:82:31)
    at Object.onceWrapper (node:events:510:26)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Socket.<anonymous> (node:internal/child_process:450:11)
    at Socket.emit (node:events:390:28)
    at Pipe.<anonymous> (node:net:687:12) {
  stderr: '\x1B[31m\x1B[0mThere are some problems with the configuration, described below.\n' +
    '\n' +
    'The Terraform configuration must be valid before initialization so that\n' +
    'Terraform can determine which modules and providers need to be installed.\x1B[0m\x1B[0m\n' +
    '\x1B[31m\x1B[31m╷\x1B[0m\x1B[0m\n' +
    '\x1B[31m│\x1B[0m \x1B[0m\x1B[1m\x1B[31mError: \x1B[0m\x1B[0m\x1B[1mNo configuration for provider aws.alternate\x1B[0m\n' +
    '\x1B[31m│\x1B[0m \x1B[0m\n' +
    '\x1B[31m│\x1B[0m \x1B[0m\x1B[0m  on main.tf.json line 1, in module:\n' +
    '\x1B[31m│\x1B[0m \x1B[0m   1: {"terraform":{},"module":{"<my_module>":\x1B[4m{\x1B[0m"source":"git::<git-repo>"}}}\x1B[0m\n' +
    '\x1B[31m│\x1B[0m \x1B[0m\n' +
    '\x1B[31m│\x1B[0m \x1B[0mConfiguration required for\n' +
    '\x1B[31m│\x1B[0m \x1B[0mmodule.<my_module>.provider["registry.terraform.io/hashicorp/aws"].alternate.\n' +
    '\x1B[31m│\x1B[0m \x1B[0mAdd a provider named aws.alternate to the providers map for\n' +
    '\x1B[31m│\x1B[0m \x1B[0mmodule.<my_module>\n' +
    '\x1B[31m│\x1B[0m \x1B[0min the root module.\n' +
    '\x1B[31m╵\x1B[0m\x1B[0m\n' +
    '\x1B[0m\x1B[0m\n'
}
⠼ downloading and generating modules and providers...
non-zero exit code 1

So my question now is is it possible to use the pre-built AWS provider and get my configuration working with two AWS providers or must I download the AWS provider which takes a long time and make aws and aws.alternate reference it.

I am afraid I am still stuck.

_Originally posted by @nandac in https://github.com/hashicorp/terraform-cdk/issues/1383#issuecomment-989863738_

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nandaccommented, Dec 13, 2021

@jsteinich Thank you for your help with my issue.

I have finally got it working by skipping the cdktf get step and just going straight to cdktf synth.

I did however have to create an empty imports directory manually for cdktf synth to work without generating an error.

After that everything worked according to the post you had pointed me to earlier.

I had already tried the second methodology of making the module self-contained, by specifying the provider within but it was not something I considered to be a production-ready solution.

I am keen to see progress on a fix of this issue sometime in the future.

0reactions
github-actions[bot]commented, Nov 25, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Help! Provider aliases no longer working since .14 - Terraform
My use case is defining multiple accounts or regions in provider blocks, then calling them as aliases to deploy modules. Terraform Provider ......
Read more >
Can you remember "Can't bind 'x' since it is not a known ...
This error often means that you haven't declared the directive "x" or haven't imported the NgModule to which "x" belongs.
Read more >
Can't bind to 'ngIf' since it isn't a known property of 'div' in ...
Getting error only in production build. I have used import { CommonModule } from '@angular/common'; imports: ...
Read more >
Navigate the component tree with DI - Angular
Unable to find a parent by its base classlink ... Write an alias provider —a provide object literal with a useExisting definition— that...
Read more >
Android - Dagger
It also makes it easy to create reusable, interchangeable modules. ... Note: Using @Binds is the preferred way to define an alias because...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found