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

BREAKING CHANGE: update module to include latest features and remove use of count for module count/for_each #234

Conversation

bryantbiggs
Copy link
Member

@bryantbiggs bryantbiggs commented Aug 26, 2021

Description

  • update module to include latest features and remove use of count for module count/for_each
  • basic example renamed to complete - no longer just basic and shows multiple examples for more of a complete setup

New attributes added

  • hibernation
  • secondary_private_ips
  • capacity_reservation_specification
  • launch_template
  • enclave_options
  • host_id
  • timeouts

Removed variables

  • instance_count
  • subnet_ids
  • private_ips
  • use_num_suffix
  • num_suffix_format

Renamed outputs

  • :info: All outputs used to be lists, and are now singular outputs due to the removal of count

Removed Outputs

  • availability_zone
  • placement_group
  • key_name
  • ipv6_addresses
  • private_ip
  • security_groups
  • vpc_security_group_ids
  • subnet_id
  • credit_specification
  • metadata_options
  • root_block_device_volume_ids
  • ebs_block_device_volume_ids
  • volume_tags
  • instance_count

Motivation and Context

  • with the introduction of module level count and for_each, this means users can create as many ec2 instances as necessary with the module as opposed to the module itself trying to control how many instances are created. in addition, the use of for_each is preferred to avoid disruptive updates that can be encountered when using count and modifying one of the resources within the list

Closes #92
Closes #160
Closes #173
Closes #188
Closes #213
Closes #230

Breaking Changes

  • Yes, see UPGRADE-3.0.md for upgrade instructions

How Has This Been Tested?

  • I have tested and validated these changes using one or more of the provided examples/* projects
    • examples updated and validated for new changes

@bryantbiggs bryantbiggs force-pushed the chore/update-to-latest-features branch from 8f37e88 to 23d9a3f Compare August 26, 2021 12:34
Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

Great to see this amount of improvements!

examples/complete/versions.tf Outdated Show resolved Hide resolved
examples/complete/main.tf Show resolved Hide resolved
.github/workflows/pre-commit.yml Outdated Show resolved Hide resolved
UPGRADE-3.0.md Show resolved Hide resolved
@bryantbiggs bryantbiggs force-pushed the chore/update-to-latest-features branch from df2c942 to bed9dd0 Compare August 26, 2021 14:13
@bryantbiggs bryantbiggs force-pushed the chore/update-to-latest-features branch from bed9dd0 to 886e576 Compare August 26, 2021 14:26
@bryantbiggs bryantbiggs force-pushed the chore/update-to-latest-features branch from 8630a90 to 8ff1dd5 Compare August 26, 2021 14:34
@bryantbiggs bryantbiggs marked this pull request as ready for review August 26, 2021 14:34
@bryantbiggs
Copy link
Member Author

my local terraform-docs is @ v0.15 and hence the diff in the lint check 🤷🏼‍♂️

@antonbabenko
Copy link
Member

my local terraform-docs is @ v0.15 and hence the diff in the lint check 🤷🏼‍♂️

I stopped managing terraform-docs with homebrew and downloaded 0.13 which we use everywhere :)

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

LGTM

# EC2 Multiple
output "ec2_multiple" {
description = "The full output of the `ec2_module` module"
value = module.ec2_multiple
Copy link
Member

Choose a reason for hiding this comment

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

Output for lazy people :)

@antonbabenko
Copy link
Member

I fixed the docs, is there anything else in this PR?

@bryantbiggs
Copy link
Member Author

Thank you! No, I think we should be all set - I'll keep an eye in case any issues start popping up

@antonbabenko antonbabenko merged commit 2d92dfe into terraform-aws-modules:master Aug 26, 2021
@bryantbiggs bryantbiggs deleted the chore/update-to-latest-features branch August 26, 2021 14:54
@antonbabenko
Copy link
Member

Cool, v3.0.0 has been just released.

@firke
Copy link

firke commented Sep 2, 2021

hey @bryantbiggs @antonbabenko, thank you for your work on this! Quick question in regards to this release - what was the reasoning behind removing some of the outputs, e.g. availability_zone/private_ip?

@antonbabenko
Copy link
Member

The main reason for that is that those attributes (outputs) are not in the resource itself (see aws_instance docs).

We probably had them in the past but they were actually arguments (inputs).

@firke
Copy link

firke commented Sep 2, 2021

@antonbabenko so I think Hashicorp have changed layout of docs a little, and outputs block does not explicitly mention all of the outputs, as it also includes inputs as part of outputs. This is listed in outputs part of docs:
In addition to all arguments above, the following attributes are exported
This would include private_ip as part of output.

I've tested it with a forked version - https://github.com/firke/terraform-aws-ec2-instance
Only private_ip output was added as part of test. Once used, private_ip attribute was available to other resources, route53 record as an example:

resource "aws_route53_record" "private_dns" {
  zone_id = data.terraform_remote_state.network.outputs.private_zone_id
  name    = "rpc"
  type    = "A"
  ttl     = "300"
  records = [module.ec2.private_ip]
}

@antonbabenko
Copy link
Member

You are absolutely right, you could always use arguments as outputs. And we sometimes did this (and maybe still do) to implement poor-man depends_on solutions but this is not needed in this module.

@firke
Copy link

firke commented Sep 2, 2021

Ah, I see, this clicked with me just recently about the docs. So using same example of private_ip, referencing which should be a trivial task, my understanding is just now without these outputs it's not possible, and if these are not returned will either need to use forked version or use a data source for an ec2_instance object? Sorry if I've missed something. :)

Added: slight clarification as well - i'm not setting private_ip as part of module, but it is still available as output.

@antonbabenko
Copy link
Member

You're right about using the data-source aws_instance as a fetcher for the data you need based on EC2 instance id.

@suppix
Copy link

suppix commented Sep 22, 2021

@antonbabenko Looks like it's not so handy, especially to use this module with terragrunt.

@antonbabenko
Copy link
Member

This module creates an EC2 instance so that it is possible to get some more information about the resource using data source in other places. In terragrunt you can use generate block to create extra data-source code or make a small module that will act as a fetcher/bridge.

@antonbabenko antonbabenko mentioned this pull request Oct 6, 2021
@github-actions
Copy link

github-actions bot commented Nov 8, 2022

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants