Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
f3-esajid opened this issue May 19, 2025 · 1 comment
Open
1 task done

Comments

@f3-esajid
Copy link

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.

@f3-esajid
Copy link
Author

creating new instances is getting break due to this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant