Tevfik Sastım
Tevfik Sastım

Reputation: 31

An argument or block definition is required here. To set an argument, use the equals sign "=" to introduce the │ argument value

I am new in Terraform, and I receive the following error when I used terraform apply in my cmd: An argument or block definition is required here. To set an argument, use the equals sign "=" to introduce the │ argument value.
Here is my code:

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "3.67.0"
    }
  }
}

provider "aws" {
  profile = "user1"  
  region = "eu-west-3"
  access_key = "133634"
  secret_key = "133634"
}

data.aws_vpc.gelistirici-vpc? {
  id = var.vpc_id
}

resource "aws_subnet" "gelistirici-vpc" {
  cidr_block = "10.0.0.0/16"
}

resource "aws_subnet" "dev-subnet-1" {
  vpc_id = aws_vpc.gelistirici-vpc.id
  cidr_block = "10.0.10.0/24"
  avaliability_zone = "eu-west-3a"
}
 Error: Argument or block definition required
│
│   on main.tf line 18:
│   18: data.aws_vpc.gelistirici-vpc?{
│
│ An argument or block definition is required here. To set an argument, use the equals sign "=" to introduce the
│ argument value.

How can I solve this? Thanks in advance

Upvotes: 0

Views: 5722

Answers (2)

Tevfik Sastım
Tevfik Sastım

Reputation: 31

The problem is about my AWS credentials, more specifically my public and private keys. Once I downloaded to them from my AWS account, the error vanished. Now the code is working w/o an error.

Upvotes: 0

Dan Monego
Dan Monego

Reputation: 10087

Instead of:

data.aws_vpc.gelistirici-vpc? { ... }

use:

data "aws_vpc" "gelistirici-vpc" { ... }

You may also want to set the VPC on the "gelistirici-vpc" subnet, but that shouldn't cause an error.

Upvotes: 1

Related Questions