How to output name of a resource from module in terraform

I have been trying to figure out how to output the "name" parameter of a resource in Terraform so I can then use this in other modules. This is my best attempt so far: resource "azurerm_resource_group" "rg_infrastructure" { name = "rg_${var.environment}_Infrastructure" location = var.location } output "rg_infrastructureName" { value = module.rg_infrastructure.name # <- How to… Read More How to output name of a resource from module in terraform

How to read double-quoted string values using terraform csvdecode?

I have a CSV file that contains the following content: id,value 123,{"M":{"name_1":{"S":"value_1"}, "name_2":{"S":"value_2"}}} I’m trying to read this CSV file and create records in DynamoDB the following way: locals { custom_data = csvdecode(file("${path.module}/../custom_data.csv")) } resource "aws_dynamodb_table_item" "custom_table_item" { for_each = {for row in local.custom_data : row.id => row} table_name = aws_dynamodb_table.custom_table.name hash_key = aws_dynamodb_table.custom_table.hash_key item… Read More How to read double-quoted string values using terraform csvdecode?

How to instruct module to use particular provider in terraform?

I want to create a module that is linked to my artifactory provider. In my config.tf where I have configured my providers, I also have hashicorp/aws defined like below… terraform { required_version = "~> 1.2.4" required_providers { aws = { version = "4.64.0" source = "hashicorp/aws" } artifactory = { version = "6.22.3" source =… Read More How to instruct module to use particular provider in terraform?

How to resolve Terraform module to correct repo

In golang, I’m building an application that will return info about any Terraform Public Registry module. The application needs to see the files themselves. For instance, consider this module. Version 3.8.2 will resolve to this git repo and ref. The user provides: source = "terraform-aws-modules/s3-bucket/aws" version = "3.8.2" And Terraform knows where to get the… Read More How to resolve Terraform module to correct repo

Created lambda resource based policy statement using Terraform but it does not show in AWS Lambda Console

Here’s the terraform script snippet I used to create a lambda resource based policy resource "aws_lambda_permission" "allow_eventbridge_execution" { statement_id = "AllowExecutionFromEventBridge" action = "lambda:InvokeFunction" function_name = aws_lambda_function.this.arn principal = "events.amazonaws.com" source_arn = aws_cloudwatch_event_rule.this.arn qualifier = aws_lambda_alias.latest.name source_account = local.aws_account_id } resource "aws_lambda_alias" "latest" { name = "latest-version" description = "An alias to the latest version… Read More Created lambda resource based policy statement using Terraform but it does not show in AWS Lambda Console

Can't access attributes on a list of objects in terraform

Trying to create a dynamic block based on a list of objects. Here is the attempt data "vault_policy_document" "this" { dynamic "rule" { for_each = { for p in var.policy : format("%s-%s", p.path, join(",", p.capabilities)) => p } content { path = rule.value.path capabilities = rule.value.capabilities } } } and here is the input var.policy… Read More Can't access attributes on a list of objects in terraform