Skip to content

Unconfigurable attribute "domain" error in EC2 module with EIP enabled #431

Open
@f3-esajid

Description

@f3-esajid

Description

I'm encountering an error when setting create_eip = true in the module. The module fails during apply with the following error:

Error: Value for unconfigurable attribute

  with module.ec2_instance.aws_eip.this,
  on .terraform/modules/ec2_instance/main.tf line 619, in resource "aws_eip" "this":
  619:   domain = var.eip_domain

Can't configure a value for "domain": its value will be decided automatically based on the result of applying this configuration.

It appears the module is explicitly setting the domain argument on the aws_eip resource, which is now inferred automatically by the AWS provider and should no longer be set manually.

Minimal reproducible configuration:

module "ec2_instance" {
  source                        = "terraform-aws-modules/ec2-instance/aws"
  name                          = "test-ec2"
  ami                           = "ami-025685dfa31c58aa4"
  instance_type                 = "t3.micro"
  subnet_id                     = "subnet-12345678"
  vpc_security_group_ids        = ["sg-12345678"]
  associate_public_ip_address   = true
  create_eip                    = true
  monitoring                    = true
  disable_api_termination       = true
  instance_initiated_shutdown_behavior = "stop"
  create_iam_instance_profile   = true
  iam_role_name                 = "test-role"
  iam_instance_profile          = "test-profile"
  iam_role_policies = {
    AmazonSSMManagedInstanceCore = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
  }
  root_block_device = [{
    volume_type           = "gp3"
    volume_size           = 20
    delete_on_termination = true
  }]
}
  • ✋ I have searched the open/closed issues and my issue is not listed.

⚠️ Note

  • .terraform directory has been deleted
  • Project was reinitialized with terraform init
  • Issue confirmed to persist after retries

Versions

  • Module version [Required]: v5.7.0
  • Provider version(s):
provider registry.terraform.io/hashicorp/aws v5.51.0

Reproduction Code [Required]

module "ec2_instance" {
  source                        = "terraform-aws-modules/ec2-instance/aws"
  name                          = "test-ec2"
  ami                           = "ami-025685dfa31c58aa4"
  instance_type                 = "t3.micro"
  subnet_id                     = "subnet-12345678"
  vpc_security_group_ids        = ["sg-12345678"]
  associate_public_ip_address   = true
  create_eip                    = true
  monitoring                    = true
  disable_api_termination       = true
  instance_initiated_shutdown_behavior = "stop"
  create_iam_instance_profile   = true
  iam_role_name                 = "test-role"
  iam_instance_profile          = "test-profile"
  iam_role_policies = {
    AmazonSSMManagedInstanceCore = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
  }
  root_block_device = [{
    volume_type           = "gp3"
    volume_size           = 20
    delete_on_termination = true
  }]
}

Expected behavior

Terraform should provision the EC2 instance and automatically associate an Elastic IP using the module.

Actual behavior

Terraform errors during plan/apply due to unconfigurable domain argument being set inside the module.

Terminal Output Screenshot(s)

Error: Value for unconfigurable attribute
│ 
│   with module.ec2_instance.aws_eip.this,
│   on .terraform/modules/ec2_instance/main.tf line 619, in resource "aws_eip" "this":
│  619:   domain = var.eip_domain
│ 
│ Can't configure a value for "domain": its value will be decided automatically based on the result of applying this configuration.

Additional context

This likely stems from a change in AWS provider behavior where the domain attribute in aws_eip is now inferred automatically. The module should remove or guard against setting domain explicitly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions