Skip to content
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

The default value ebs_optimized = true makes some instance types unable to provision. #174

Open
soya-miyoshi opened this issue Sep 12, 2023 · 3 comments
Labels
bug 🐛 An issue with the system

Comments

@soya-miyoshi
Copy link

Describe the Bug

Because the default value of ebs_optimized changed to true in this PR #159, some instance types (such as t2.micro) are unable to provision because they are simply unsupported for EBS-optimized instances.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-optimized.html

So the following code causes an error:

module "my-ec2" {
  source  = "cloudposse/ec2-instance/aws"
  version = "1.1.0"

  vpc_id = module.shared_vpc.vpc_id

  ami              = "ami-06fdbb60c8e83aa5e"
  instance_type    = "t2.micro"
  ami_owner        = "137112412989"
  subnet           = module.shared_dynamic_subnets.private_subnet_ids[0]
}
 Error: creating EC2 Instance: Unsupported: The requested configuration is currently not supported. Please check the documentation for supported configurations.

Expected Behavior

EC2 instances of types that do not support EBS-optimized configurations can still be provisioned using default values.

Steps to Reproduce

Terraform v1.5.6

aws = {
source = "hashicorp/aws"
version = ">=5.12.0, <6.0.0"
}

Then applying the code above will reproduce.

Screenshots

No response

Environment

No response

Additional Context

No response

@soya-miyoshi soya-miyoshi added the bug 🐛 An issue with the system label Sep 12, 2023
@soya-miyoshi soya-miyoshi changed the title The default value ebs_optimized = true makes some instance types non-configurable. The default value ebs_optimized = true makes some instance types non able to provision. Sep 12, 2023
@soya-miyoshi soya-miyoshi changed the title The default value ebs_optimized = true makes some instance types non able to provision. The default value ebs_optimized = true makes some instance types unable to provision. Sep 12, 2023
@haidargit
Copy link
Contributor

haidargit commented Jan 21, 2024

Hi, this isn't a bug actually.. 👍🏻

as far as i know, the ec2 module (terraform-aws-ec2-instance) from cloudposse provides a variable to control the ebs_optimized argument.

There are various ways for us to do that.

( using *.tfvars )
you can declare your own variable, for example,

add this code inside your "main.tf" or "variables.tf"

variable "ebs_optimized" {
  type        = bool
  description = "Launched EC2 instance will be EBS-optimized"
  default     = true
}


create a file "example.tfvars" and add this line inside of it
ebs_optimized = "false"

then simply use the cloudposse module like this

module "my-ec2" {
  source  = "cloudposse/ec2-instance/aws"
  version = "1.1.0"

 . . . some code . . .

 ebs_optimized = var.ebs_optimized

 . . . some code . . .
}

run your resource
terraform apply -var-file"example.tfvars"

OR...

(straightforward)

module "my-ec2" {
  source  = "cloudposse/ec2-instance/aws"
  version = "1.1.0"

 . . . some code . . .

 ebs_optimized = false

 . . . some code . . .
}

@haidargit
Copy link
Contributor

ref:

variable "ebs_optimized" {

@soya-miyoshi
Copy link
Author

@haidargit
Thank you for getting back to me.
You can indeed supply ebs_optimized = false to this module. However, I would like to point out that it would be more straightforward if ebs_optimized = false was the default value so that it is compatible with the previous version of this module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

2 participants