terraform-aws-ec2-instance
terraform-aws-ec2-instance copied to clipboard
Unconfigurable attribute "domain" error in EC2 module with EIP enabled
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
}]
}
- [x] β I have searched the open/closed issues and my issue is not listed.
β οΈ Note
.terraformdirectory 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.
creating new instances is getting break due to this
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
This issue was automatically closed because of stale in 10 days
I'm going to lock this issue because it has been closed for 30 days β³. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.