module. is a object, known only after apply

I'm trying to create a ssm parameter in aws for dyanamo db table with name and arn so it can be referenced by another application. I've tried a few different things but can't figure out what I'm doing wrong here. Can anyone tell me what is wrong here?

Thank you

Here's my main file with the module.

main.tf

locals {
  prefix = "/this/is/a/test"
}

module "test_table" {
  source = "git@github.com:test/terraform-modules.git//dynamodb"

  name                  = "dynamo-${local.environment}"
  ssm_parameter_prefix  = local.prefix

  tags = {
    Environment  = local.environment
  }
}

resource "aws_ssm_parameter" "table_name" {
  provider = aws.east
  name     = "${local.prefix}/new/table-name"
  type     = "String"
  value    = module.test_table.name
}

resource "aws_ssm_parameter" "table_arn" {
  provider = aws.east
  name     = "${local.prefix}/new/table-arn"
  type     = "String"
  value    = module.test_table.arn
}

Here is the output

outputs.tf

output "test_table" {
  value = module.test_table
}

output "table_arn" {
  value       = module.test_table.arn
}

output "table_name" {
  value       = module.test_table.name
}

Terraform Error

│ Error: Unsupported attribute
│ 
│   on dynamo.tf line, in resource "aws_ssm_parameter" "table_name":
│  118:   value    = module.test_table.name
│     ├────────────────
│     │ module.test_table is a object, known only after apply
│ 
│ This object does not have an attribute named "name".
╵
╷
│ Error: Unsupported attribute
│ 
│   on dynamo.tf line, in resource "aws_ssm_parameter" "table_arn":
│  125:   value    = module.test_table.arn
│     ├────────────────
│     │ module.test_table is a object, known only after apply
│ 
│ This object does not have an attribute named "arn".
╵


Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)