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

feat: Add allowed_instance_types to instance_requirements #267

Merged
merged 3 commits into from
May 28, 2024

Conversation

baolsen
Copy link
Contributor

@baolsen baolsen commented May 15, 2024

Description

The aws_launch_template resource supports an allowed_instance_types field in the instance_requirements block.

allowed_instance_types - (Optional) List of instance types to apply your specified attributes against. All other instance types are ignored, even if they match your specified attributes. You can use strings with one or more wild cards, represented by an asterisk (), to allow an instance type, size, or generation. The following are examples: m5.8xlarge, c5., m5a., r*, 3. For example, if you specify c5*, you are allowing the entire C5 instance family, which includes all C5a and C5n instance types. If you specify m5a.*, you are allowing all the M5a instance types, but not the M5n instance types. Maximum of 400 entries in the list; each entry is limited to 30 characters. Default is all instance types.

NOTE: If you specify allowed_instance_types, you can't specify excluded_instance_types.

This terraform module does already accept the excluded_instance_types field but not the allowed_instance_types field documented on the resource.

Motivation and Context

Closes #265

Breaking Changes

No - I've included an update the excluded_instance_types to ensure compatibility when either field is present.

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

@baolsen
Copy link
Contributor Author

baolsen commented May 15, 2024

Additional tests I did locally:

Terraform plan with the following combinations:
1

allowed_instance_types = ["c6in.xlarge"]

=> works

2

excluded_instance_types = ["c6in.xlarge"]

=> works

3

<none>

=> works

4

allowed_instance_types = ["c6in.xlarge"]
excluded_instance_types = ["c6in.xlarge"]

=> 
Planning failed. Terraform encountered an error while generating this plan.
Error: Conflicting configuration arguments
"instance_requirements.0.allowed_instance_types": conflicts with instance_requirements.0.excluded_instance_types
Error: Conflicting configuration arguments
"instance_requirements.0.excluded_instance_types": conflicts with instance_requirements.0.allowed_instance_types

The failure in test 4 was expected.

@baolsen
Copy link
Contributor Author

baolsen commented May 16, 2024

I see there is an issue template that for some reason I didn't see when creating this :)
Will update the description accordingly
Edit: Done

@baolsen
Copy link
Contributor Author

baolsen commented May 27, 2024

@antonbabenko , ready for review

@bryantbiggs
Copy link
Member

the min required AWS provider version throughout will need to be raised to 5.45 to support this

…` parameter and for ALB module updates in examples
@baolsen
Copy link
Contributor Author

baolsen commented May 28, 2024

Thank you @bryantbiggs

I had to go with 5.46 here to cater for the min version needed on https://registry.terraform.io/modules/terraform-aws-modules/alb/aws/9.9.0.

Basically, I can't use 5.45 here without also constraining the ALB module in the example to <9.9.0

Happy to do that if you think its worth it

Also added a note to the README re contributions.

README.md Outdated Show resolved Hide resolved
@bryantbiggs
Copy link
Member

The min version is to declare the modules minimum requirements - it doesn't mean you can pin to this exact version in an example because the use of other resources/modules in an example may require a higher version. It is just a lower bound pin to declare the minimum requirements for the module itself; Terraform will use this when resolving the version requirements in conjunction with other modules and user defined version requirements

@baolsen
Copy link
Contributor Author

baolsen commented May 28, 2024

@bryantbiggs thank you, should be sorted now

@bryantbiggs bryantbiggs changed the title feat: Add allowed_instance_types to instance_requirements (#265) feat: Add allowed_instance_types to instance_requirements May 28, 2024
@bryantbiggs bryantbiggs merged commit 09d8e0f into terraform-aws-modules:master May 28, 2024
7 checks passed
antonbabenko pushed a commit that referenced this pull request May 28, 2024
## [7.5.0](v7.4.1...v7.5.0) (2024-05-28)

### Features

* Add `allowed_instance_types` to `instance_requirements` ([#267](#267)) ([09d8e0f](09d8e0f)), closes [#265](#265)
@antonbabenko
Copy link
Member

This PR is included in version 7.5.0 🎉

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

Successfully merging this pull request may close these issues.

Unable to define allowed_instance_types when defining a launch_template
3 participants