Hi Team,
I have a simple code where I am taking csv file as input and passing headers as arguments in resource, similar below but getting an error managed resource local has not been declared
locals {
instancesdefaultpassword = csvdecode(file("./defaultPasswordPolicy.csv"))
}
resource "okta_policy_password_default" "default" {
password_min_length = locals.instancesdefaultpassword.password_min_length
}
can someone suggest why I am getting this error, I don’t want to use for-each loop in this case.
Regards
Rahul Jha
The error is probably not about “local”, but rather A managed resource "locals" ...
, because there is a typo in the password_min_length
value. Try using
password_min_length = local.instancesdefaultpassword.password_min_length
1 Like
Hi Jbardin,
Still the same error,
My csv file looks like below which I am trying to read and set the argument in resource
password_min_length,password_min_lowercase,password_min_uppercase,password_exclude_username,password_history_count,password_max_lockout_attempts,password_min_symbol,sms_recovery,call_recovery,email_recovery,question_recovery
8,1,1,ACTIVE,4,3,1,ACTIVE,ACTIVE,ACTIVE,ACTIVE
Regards
That error is different from the first, now explaining that local.instancesdefaultpassword
is a list of objects, containing a single element. The suggestion is to access an attribute of a single object by first indexing the list to get a specific element. If you know the list only contains a single value, then:
password_min_length = local.instancesdefaultpassword[0].password_min_length
You can also use the one
function when you know you are always looking for a single item in a list.
Hi jbardin,
I am getting the below mentioned error. Need your help to resolve it.
│ Error: Reference to undeclared resource
│
│ on routing lambda.tf line 175, in resource “aws_lambda_event_source_mapping” “Devops_mapping”:
│ 175: event_source_arn = aws_dynamodb_table.Devops_mapping.stream_arn
│
│ A managed resource “aws_dynamodb_table” “Devops_mapping” has not been declared in the root module.
Hi @shantanuskapse,
The error indicates that there is no resource called "aws_dynamodb_table” “Devops_mapping"
in your root module, but without any configuration we can’t offer additional assistance. If you need more help than that, feel free to create a new topic, with a minimal, complete example which demonstrates the problem you are facing.