Tho Quach
Tho Quach

Reputation: 1425

Terraform plan err: Unsupported argument

I have a resource like this repo/dynamo/main.tf:

resource "aws_dynamodb_table" "infra_locks" {
  name         = "infra-locks"
  billing_mode = "PAY_PER_REQUEST"
  hash_key     = "LockID"
  attribute {
    name = "LockID"
    type = "S"
  }
}

And I refer above file as a module follow github repo

Tf file where I refer to above file repo/example/main.tf:

provider "aws" {
  region = var.region
}

module "dynamodb_table" {
  source = "../dynamodb_table"

  name      = "my-table"
}

I have terraform init success but fail when run terraform plan


Error: Unsupported argument

  on main.tf line 14, in module "dynamodb_table":
  14:   name      = "my-table"

An argument named "name" is not expected here.

How can i fix this? Tks in advance

Upvotes: 2

Views: 1070

Answers (1)

Tho Quach
Tho Quach

Reputation: 1425

As @luk2302 has said:

resource "aws_dynamodb_table" "infra_locks" {}

The above resource exactly has name attribute but it 's not a variable so we can not assign anything to it.

There is a confused right here. I have fixed by change a little bit: repo/dynamo/main.tf

resource "aws_dynamodb_table" "infra_locks" {
  name         = var.name
  billing_mode = "PAY_PER_REQUEST"
  hash_key     = "LockID"
  attribute {
    name = "LockID"
    type = "S"
  }
}

repo/dynamo/variable.tf

variable "name" {
  description = "dynamo table name"
  default     = null
}

And final, we can configure your dynamo_table 's name.

Upvotes: 1

Related Questions