amazon-web-servicesterraformhashicorp

Terraform aws_eip resource getting "Error" of Value for unconfigurable attribute


I am new to Terraform and following a tutorial on how to create aws_elasticip module. When i perform 'terraform plan' this issue is present and i can't move forward with creating my terraform file.

 terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.16"
    }
  }
}

provider "aws" {
  region = "eu-west-2"
}

resource "aws_eip" "lb" {
  domain = "vpc"
}

I have also attempted to do this with a instance variable declared and the error still persists

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.16"
    }
  }
}

provider "aws" {
  region = "eu-west-2"
}

resource "aws_vpc" "vpc_a" {
  cidr_block = "10.0.0.0/16"
}

resource "aws_instance" "server_a" {
    ami = "ami-06464c878dbe46da4"
    instance_type = "t2.micro"
}

resource "aws_eip" "lb" {
    instance = aws_instance.server_a.id
    domain = "vpc"
}

The error I am getting is below.

│ Error: Value for unconfigurable attribute
│ 
│   with aws_eip.lb,
│   on main.tf line 25, in resource "aws_eip" "lb":
│   25:     domain = "vpc"
│ 
│ Can't configure a value for "domain": its value will be decided
│ automatically based on the result of applying this configuration.

Solution

  • The semantic versioning specification you provided in the config for the provider block is ~> 4.16 which resolves to >= 4.16 < 5.0.0. The domain parameter was migrated from a Computed attribute to an input attribute in the aws_eip resource in version 5.0.0 as a pseudo-replacement for the vpc parameter. You would need to upgrade the AWS provider to a minimum of 5.0.0 to use this parameter.