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(aws_instance): add instance market options block #202

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

haidargit
Copy link
Contributor

@haidargit haidargit commented Aug 4, 2024

what

  • The PR enables the terraform instance_market_options block for this ec2 module
  • add a new tfvars as a consumer/Terratest for the ec2 spot instance inside examples/complete directory

why

  • Spot Instances can offer a great discount compared to On-Demand pricing based on AWS documentation

references

  • there are no issues related to this PR, this PR is made for the ec2 module improvement

others:

  • module documentation is updated (guide: Updating Module Documentation)

  • update the versions.tf files in the example directories as a complement (guide: Updating the Module Examples)

  • (done) terraform testing (plan+apply) is performed by using examples/complete directory on current PR branch feature/spot-instance-enablement targeting self-owned AWS cloud account

@haidargit haidargit requested review from a team as code owners August 4, 2024 12:32
@mergify mergify bot added the triage Needs triage label Aug 4, 2024
@haidargit
Copy link
Contributor Author

Hello @hans-d & @jamengual

please review the PR above for the ec2 module improvement
any input is welcome 🙂

Thank you

@haidargit haidargit force-pushed the feature/spot-instance-enablement branch from c078527 to 48ebfae Compare August 4, 2024 12:40
Copy link
Member

@joe-niland joe-niland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @haidargit - a couple of comments

variables.tf Show resolved Hide resolved
variables.tf Outdated Show resolved Hide resolved
Copy link

mergify bot commented Aug 17, 2024

💥 This pull request now has conflicts. Could you fix it @haidargit? 🙏

@mergify mergify bot added conflict This PR has conflicts and removed conflict This PR has conflicts labels Aug 17, 2024
@haidargit
Copy link
Contributor Author

make init && make readme have been re-ran, @joe-niland, Thank you

@nitrocode
Copy link
Member

That new example directory isn't getting run by terratest. Was adding the example strictly as a way of documenting the feature?

Here are some options worth considering

  1. How come we can't make the existing tfvars test use the new input? This would be ideal.

  2. If that's not possible, is it possible to add a new tfvars in the existing examples complete directory instead of adding a new terraform example directory? If so that would be advisable because it would be less code to maintain and update.

  3. As-is (example directory, no automated test)


Here is the existing tfvars https://github.com/cloudposse/terraform-aws-ec2-instance/blob/main/examples/complete/fixtures.us-east-2.tfvars which could then have an additional tfvars beside it such as fixtures.us-east-2.spot.tfvars.

Here is how the tfvars get inserted into the test

VarFiles: []string{"fixtures.us-east-2.tfvars"},

@haidargit
Copy link
Contributor Author

Hi @nitrocode, thanks for the insight

Correct, using the existing example directories is sufficient.

i have updated my code to use the current /complete test directory, these are the changes that may be applicable:

  • i have created the fixtures.us-east-2.spot.tfvars as new tvfars. I just left the current tfvars as is inside the examples/complete directory, so the user/terratest able to provision a sample of an EC2 instance with the spot instance disabled. The new tvfars will introduce this new variable instance_market_options_enabled = true

  • modified the test/src/examples_complete_test.go to include new tfvars and spot instance request ID output test

for the terratest reference, the output ID prefix is sir-
spot_instance_request id_sir

outputs.tf Outdated Show resolved Hide resolved
variables.tf Outdated Show resolved Hide resolved
@nitrocode
Copy link
Member

Thanks for addressing the changes.

How come the _enabled flag is still used? I thought it was removed when this comment was raised?

#202 (comment)

@haidargit haidargit force-pushed the feature/spot-instance-enablement branch from 9259333 to 3389dbb Compare September 1, 2024 04:09
Copy link

mergify bot commented Sep 19, 2024

💥 This pull request now has conflicts. Could you fix it @haidargit? 🙏

@mergify mergify bot added conflict This PR has conflicts and removed conflict This PR has conflicts labels Sep 19, 2024
@nitrocode
Copy link
Member

/terratest

@nitrocode
Copy link
Member

@haidargit see code annotations and test failures

@nitrocode
Copy link
Member

Thanks for resolving some of the issues.

There seem to be a few remaining. Please fix all of them and then resubmit the PR. I moved it to a draft for now.

@nitrocode nitrocode marked this pull request as draft September 21, 2024 18:30
@haidargit
Copy link
Contributor Author

Hi @nitrocode,
i adjusted the output.tf files on the spot instance part to use length function to fix the tflint warnings

Could you kindly review the latest commit when you get a chance? Much appreciated!

@haidargit haidargit marked this pull request as ready for review September 21, 2024 22:16
@haidargit haidargit force-pushed the feature/spot-instance-enablement branch from 5aab533 to c184687 Compare October 4, 2024 15:06
@haidargit
Copy link
Contributor Author

Hello @nitrocode, @joe-niland

I've updated the code. Could you help review the latest commit? c184687

the changes included the instance market options variable adjustment, custom validation for market type, and several other minor fix

Thank you 🙏🏻

@joe-niland
Copy link
Member

/terratest

@haidargit haidargit force-pushed the feature/spot-instance-enablement branch from 233c5aa to b6ae4ad Compare October 21, 2024 01:48
@nitrocode
Copy link
Member

/terratest

@joe-niland
Copy link
Member

/terratest

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

Successfully merging this pull request may close these issues.

3 participants