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:
- Created 2 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top GitHub Comments
@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 tocdktf synth
.I did however have to create an empty
imports
directory manually forcdktf 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.
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.