Terraform reports 'No module called "name of the module" is declared' in "root" module - azure-virtual-machine

I have done exploration and I want to stick customized module concept rather than to use the Azure public registry of modules.
Source code location is here
https://github.com/ameyaagashe/help_me_cross_2
I run terraform on command line with below arguments:
terraform plan -var "resource_group_name=nxt-grp-prd-manage-rgp-au-se" -var "virtual_network_name=virtual_network_1" -var "sql_subnet_name=subnet_1" -var "app_subnet_name=subnet_2" -var "application_nsg=test_nsg" -var "count_vm=2" -var "sql_host_basename=sqlvms" -var "app_host_basename=appvms" -var "storage_account_suffix=sta" -var "virtual_machine_size=Standard_B1ms" -var "virtual_machine_image_publisher=MicrosoftWindowsServer" -var "virtual_machine_image_offer=WindowsServer" -var "virtual_machine_image_sku=2012-R2-Datacenter" -var "virtual_machine_image_version=latest" -var "username=devopsadmin" -var "password=Angular12#$%"
However, I am getting errors like below:
Error: Reference to undeclared module
on ../../modules/compute/main.tf line 25, in resource "azurerm_virtual_machine" "tf-vm":
25: location = module.resourcegroup.external_rg_location
No module call named "resourcegroup" is declared in sql_vms.
Error: Reference to undeclared module
on ../../modules/compute/main.tf line 26, in resource "azurerm_virtual_machine" "tf-vm":
26: resource_group_name = module.resourcegroup.external_rg_name
No module call named "resourcegroup" is declared in sql_vms.
Error: Reference to undeclared module
on ../../modules/compute/main.tf line 27, in resource "azurerm_virtual_machine" "tf-vm":
27: network_interface_ids = [element(module.network.network_interface_ids,count.index)]
No module call named "network" is declared in sql_vms.
Error: Reference to undeclared module
on ../../modules/network/data.tf line 5, in data "azurerm_virtual_network" "tf-vn":
5: resource_group_name = module.resource_groups.external_rg_name
No module call named "resource_groups" is declared in networking.
Error: Reference to undeclared module
on ../../modules/nsg/main.tf line 3, in resource "azurerm_network_security_group" "tf-nsg":
3: location = module.resourcegroup.external_rg_location
No module call named "resourcegroup" is declared in network_security_group.
Error: Reference to undeclared module
on ../../modules/nsg/main.tf line 4, in resource "azurerm_network_security_group" "tf-nsg":
4: resource_group_name = module.resourcegroup.external_rg_name
No module call named "resourcegroup" is declared in network_security_group.
Error: Reference to undeclared input variable
on ../../modules/resourcegroup/data.tf line 2, in data "azurerm_resource_group" "tf-rg-external":
2: name = var.rg_name
An input variable with the name "rg_name" has not been declared. This variable
can be declared with a variable "rg_name" {} block.
Unable to understand the underlying issue...
I am defining all modules in their own terraform configuration files and calling them in root module?
I would sincerely appreciate your assistance.

Working through each problem individually probably won't be helpful to you in the long-term, so I'm going to offer a general sense of what's wrong and share references to help with future Terraform configurations.
Referencing module.resource_group outputs from inside module.sql_vms won't work, because Terraform module composition doesn't allow sibling modules to directly reference outputs from each other.
There is a section in the documentation that explains it:
https://www.terraform.io/docs/modules/composition.html
Outputs can only be passed from one module into another by way of the root module.
Here's an example from the Terraform documentation:
module "network" {
source = "./modules/aws-network"
base_cidr_block = "10.0.0.0/8"
}
module "consul_cluster" {
source = "./modules/aws-consul-cluster"
vpc_id = module.network.vpc_id
subnet_ids = module.network.subnet_ids
}
Once this is fixed, the next problem is the modules aren't being referenced by their correct name. According to the main.tf in the git repo, 4 modules have been declared:
module.sql_vms
module.resource_group
module.networking
module.network_security_group
Since the module is declared as resource_group, it should be referenced as such instead of resourcegroup.
Finally, a variable named rg_name should be declared inside the modules/resourcegroup/ directory. Please see the following to learn about variable declarations:
https://www.terraform.io/docs/configuration/variables.html
This may not be all the problems, but it's a start. If possible, I strongly recommend reading through the Terraform documentation on creating modules. They can be found here:
https://www.terraform.io/docs/modules/index.html

Just a heads up to check the names/spellings for the modules and elements used in the files. This error must not occur if you think everything has been done right , there might be a possibility of typo error in terraform files.

Related

Error with modules gumdrop-cli.ts metaplex

I've been testing metaplex and wanted to try testing gumdrop, I downloaded the gumdrop repo from here https://github.com/metaplex-foundation/gumdrop/ and tried running it but it didn't work. I then placed it inside the original metaplex folder (~/metaplex/js/packages/gumdrop) as I thought that would maybe fix it but I now run into this error:
C:\Users\Shady\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:843
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
^
TSError: тип Unable to compile TypeScript:
~/metaplex/js/packages/gumdrop/packages/cli/src/gumdrop-cli.ts:4:10 - error TS2305: Module '"commander"' has no exported member 'program'.
4 import { program } from 'commander';
~~~~~~~
~/metaplex/js/packages/gumdrop/packages/cli/src/gumdrop-cli.ts:11:8 - error TS2307: Cannot find module '#aws-sdk/client-sesv2' or its corresponding type declarations.
11 } from '#aws-sdk/client-sesv2';
~~~~~~~~~~~~~~~~~~~~~~~
~/metaplex/js/packages/gumdrop/packages/cli/src/gumdrop-cli.ts:13:26 - error TS2307: Cannot find module 'discord.js' or its corresponding type declarations.
13 import * as discord from 'discord.js';
copying the repo into the old location is not correct. It only causes those package issues that you saw.
To make the gumdrop cli work you
need to have yarn installed.
Should run yarn install in the packages/cli folder
Run the cli with ts-node

Resolution error: stack.regionalFact is not a function aws cdk

i'm getting this error on cdk commands lie cdk deploy. I have checked other answers but they say id:string is missing in constructor but in my code it have id written in construction structure.
My cdk version is 1.119.0. I am following a tutorial and pulled their repo. I haven't changed anything in code. Just pulled repo and changed all aws modules version to 1.119.0 as they did in tutorial. on cdk deploy i get this error while their works fine
D:\Unicorn\full-stack-serverless-cdk\step01_hello_lambda\node_modules\#aws-cdk\aws-iam\lib\principals.ts:775
return stack.regionalFact(
^
TypeError: Resolution error: Resolution error: Resolution error: Resolution error: stack.regionalFact is not a function.
Object creation stack:
at stack traces disabled.
Object creation stack:
at stack traces disabled..
at ServicePrincipalToken.resolve (D:\Unicorn\full-stack-serverless-cdk\step01_hello_lambda\node_modules\#aws-cdk\aws-iam\lib\principals.ts:775:18)
at RememberingTokenResolver.resolveToken (D:\Unicorn\full-stack-serverless-cdk\step01_hello_lambda\node_modules\#aws-cdk\core\lib\resolvable.ts:80:24)
at RememberingTokenResolver.resolveToken (D:\Unicorn\full-stack-serverless-cdk\step01_hello_lambda\node_modules\#aws-cdk\core\lib\private\resolve.ts:286:18)
at resolve (D:\Unicorn\full-stack-serverless-cdk\step01_hello_lambda\node_modules\#aws-cdk\core\lib\private\resolve.ts:212:51)
at Object.resolve [as mapToken] (D:\Unicorn\full-stack-serverless-cdk\step01_hello_lambda\node_modules\#aws-cdk\core\lib\private\resolve.ts:119:77)
at TokenizedStringFragments.mapTokens (D:\Unicorn\full-stack-serverless-cdk\step01_hello_lambda\node_modules\#aws-cdk\core\lib\string-fragments.ts:65:33)
at RememberingTokenResolver.resolveString (D:\Unicorn\full-stack-serverless-cdk\step01_hello_lambda\node_modules\#aws-cdk\core\lib\resolvable.ts:99:22)
at RememberingTokenResolver.resolveString (D:\Unicorn\full-stack-serverless-cdk\step01_hello_lambda\node_modules\#aws-cdk\core\lib\private\resolve.ts:290:23)
at resolve (D:\Unicorn\full-stack-serverless-cdk\step01_hello_lambda\node_modules\#aws-cdk\core\lib\private\resolve.ts:170:48)
at Object.resolve (D:\Unicorn\full-stack-serverless-cdk\step01_hello_lambda\node_modules\#aws-cdk\core\lib\private\resolve.ts:119:77)

How to import to module using terragrunt?

So I'm having a hard time trying to import into module when using a third-party module via terragrunt.
My terragrunt.hcl file is as follows
locals {
environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
env = local.environment_vars.locals.environment
}
terraform {
source = "git::git#github.com:cloudposse//terraform-aws-elasticsearch.git//?ref=0.26.0"
}
include {
path = find_in_parent_folders()
}
I was trying to import by using
terragrunt import module.terraform-aws-elasticsearch.aws_elasticsearch_domain.default elasticsearch
But I keep getting this error
Error: Import to non-existent module
module.terraform-aws-elasticsearch is not defined in the configuration. Please add configuration for this module before importing into it.
[terragrunt] 2021/01/25 15:23:26 Hit multiple errors:
exit status 1
So I'm wondering what's the proper module name or if that's even possible to do with Terragrunt.
Any help will be greatly appreciated!
Thanks in advance.

Missing Jam file in fresh download of boost

I religiously follow http://www.boost.org/doc/libs/1_61_0/more/getting_started/windows.html.
After downloading and unpacking the 1.61 version of boost, I tried to build it from source with the instruction from section 5.1 in this guide.
So
bootstrap
.\b2
But then I get the error:
error: Unable to load Jamfile.
error: Could not find a Jamfile in directory 'libs/config/checks/architecture'.
error: Attempted to find it with pattern '[Bb]uild.jam [Jj]amfile.v2 [Jj]amfile [Jj]amfile. [Jj]amfile.jam'.
error: Please consult the documentation at 'http://www.boost.org'.
Exactly the same as Trac issue #12173 of boost.
What is going wrong? How can I make bjam find the jam files?
Bit out of date, but I was able to get this working by getting the config submodule:
git submodule update --init libs/config
It seems like the config module is an unlisted prerequisite for some of the other modules.
This error might happen when "bootstrap.jam" is trying to load the modules of the build system from a wrong path.
Make sure that BOOST_BUILD_PATH is set to "boost*/tools/build" and that BOOST_ROOT is unset.
Example of a WRONG config:
libtorrent-rasterbar-1.2.0>set BOOST_BUILD_PATH=..\boost_1_68_0
libtorrent-rasterbar-1.2.0>set BOOST_ROOT=..\boost_1_68_0
libtorrent-rasterbar-1.2.0>b2
Jamroot.jam:1: syntax error at EOF
CXXFLAGS =
LDFLAGS =
OS = NT
building boost from source directory: ..\boost_1_68_0
boost_1_68_0/tools/build/src/build\project.jam:262: in find-jamfile from module project
error: Unable to load Jamfile.
error: Could not find a Jamfile in directory '../boost_1_68_0/libs/config/checks/architecture'.
error: Attempted to find it with pattern '[Bb]uild.jam [Jj]amfile.v2 [Jj]amfile [Jj]amfile. [Jj]amfile.jam'.
error: Please consult the documentation at 'http://www.boost.org'.
boost_1_68_0/tools/build/src/build\project.jam:325: in load-jamfile from module project
boost_1_68_0/tools/build/src/build\project.jam:64: in load from module project
boost_1_68_0/tools/build/src/build\project.jam:89: in load-used-projects from module project
boost_1_68_0/tools/build/src/build\project.jam:75: in load from module project
boost_1_68_0/tools/build/src/build\project.jam:89: in load-used-projects from module project
boost_1_68_0/tools/build/src/build\project.jam:75: in load from module project
boost_1_68_0/tools/build/src/build\project.jam:145: in project.find from module project
boost_1_68_0/tools/build/src\build-system.jam:618: in load from module build-system
..\boost_1_68_0\tools\build\src/kernel\modules.jam:295: in import from module modules
..\boost_1_68_0\tools\build\src/kernel/bootstrap.jam:139: in boost-build from module
..\boost_1_68_0\boost-build.jam:17: in module scope from module
Example of a FIXED config:
libtorrent-rasterbar-1.2.0>set BOOST_BUILD_PATH=..\boost_1_68_0\tools\build
libtorrent-rasterbar-1.2.0>set BOOST_ROOT=
libtorrent-rasterbar-1.2.0>b2
Jamroot.jam:1: syntax error at EOF
CXXFLAGS =
LDFLAGS =
OS = NT
warning: No toolsets are configured.
warning: Configuring default toolset "msvc".
warning: If the default is wrong, your build may not work correctly.
warning: Use the "toolset=xxxxx" option to override our guess.
warning: For more configuration options, please consult
warning: http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html
...patience...
...found 1058 targets...
...updating 163 targets...
msvc.write-setup-script bin\standalone\msvc\msvc-14.1\msvc-setup.bat
compile-c-c++ bin\msvc-14.1\debug\threading-multi\src\alert.obj
alert.cpp
...

error: unexpected exception No module named pydevd

I am trying to use PyDev with Eclipse. However when i start to debug my code, i get this No module found error.
My code is
global _initialized, _path, _version
# ADD THE FOLLOWING TO LINES WHERE YOU WANT TO BREAK
import pydevd
pydevd.settrace('localhost', port=5678)
# execution will stop at this line
if _initialized and _path != path and _version != version:
ERROR_HANDLER('Attempt to reconfigure with different path')
The error I get is
error: unexpected exception
No module named pydevd
Sorry, I am new to Eclipse and only working on python for 2 months. Please let me know if more information is needed.
You need to ensure pydevd is in your PYTHONPATH environment variable. This can be set through the OS or by adding it using sys.path:
sys.path.append('/path/to/pydevd.py')
File path of pydevd is usually something like:
eclipse/plugins/org.python.pydev_x.x.x/pysrc/pydevd.py