Skip to content

Terraform aws-ec2 example: hardcoded instance_type reduces flexibility #794

Description

@thetelgote

Which topic needs improvement?

terraform

Type of improvement

Add advanced example

What is the current state?

In topics/terraform/basics/aws-ec2, the EC2 instance's instance_type is
hardcoded to t2.micro in main.tf, while every other setting in this
example — ami, region, and the Name tag — is already exposed as a
variable in variables.tf. This is inconsistent with the rest of the module
and limits its usefulness as a learning/practice example, since anyone
wanting to try a different instance size (e.g. t3.micro, t2.small) has to
edit the module source directly instead of overriding a variable.

What improvement do you propose?

Add an instance_type variable to variables.tf (default: "t2.micro", so
existing behavior/docs stay unchanged), and reference var.instance_type
in main.tf instead of the hardcoded literal. This keeps the example fully
variable-driven and consistent with the rest of the file, with no breaking
change since the default matches current behavior.

Would you like to contribute this improvement?

  • Yes, I'd like to open a PR
  • No, I'm just suggesting it

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions