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

Upgrade to terraform 0.12 #394

Merged
merged 20 commits into from
Jun 19, 2019
Merged

Upgrade to terraform 0.12 #394

merged 20 commits into from
Jun 19, 2019

Conversation

nauxliu
Copy link
Contributor

@nauxliu nauxliu commented Jun 13, 2019

Description

Add Terraform 0.12 support, resolve #376

This is a fork of alex-goncharov's fork and resolved conflicts

Upgrade Guide

Remove xx_count variables from your code

  • map_accounts_count
  • map_roles_count
  • map_users_count
  • worker_group_count
  • worker_group_launch_template_mixed_count
  • worker_group_launch_template_count
  • workers_additional_policies_count

Replace strings with commas with lists

Affected attributes:

  • subnets
  • additional_security_group_ids
  • suspended_processes
  • target_group_arns
  • enabled_metrics
  • termination_policies

example:

worker_groups = [
  {
    name    = "example"
-   subnets = "subnet-123,subnet-456,subnet-789"
+   subnets = ["subnet-123", "subnet-456", "subnet-789"]
  }
]

Update worker group tags

 worker_groups = [
   {
     name = "example"
+    tags = [
+      {
+        key = "foo"
+        value = "bar"
+        propagate_at_launch = true
+      },
+    ]
   },
 ]

- worker_group_tags = {
-   default = []
-   example = [
-     {
-       key = "foo"
-       value = "bar"
-       propagate_at_launch = true
-     },
-   ]
- }

Update worker_groups_launch_template_mixed override instance types

worker_groups_launch_template_mixed = [
  {
    name                     = "spot-1"
+   override_instance_types  = ["m5.large", "c5.large", "t3.large", "r5.large"]
-   override_instance_type_1 = "m5.large"
-   override_instance_type_2 = "c5.large"
-   override_instance_type_3 = "t3.large"
-   override_instance_type_4 = "r5.large"
    spot_instance_pools      = 3
    asg_max_size             = 5
    asg_desired_size         = 5
    autoscaling_enabled      = true
    kubelet_extra_args       = "--node-labels=kubernetes.io/lifecycle=spot"
  }
]

alex-goncharov and others added 8 commits May 24, 2019 00:13
coalesce(lookup(map, key, ""), default) -> lookup(map, key, default)
* always set a value for these tags

* fix tag value

* fix tag value

* default element available

* added default value

* added a general default

without this default - TF is throwing an error when running a destroy
@nauxliu nauxliu changed the title Upgrade to terraform 0.12 [WIP] Upgrade to terraform 0.12 Jun 13, 2019
@mathuin
Copy link

mathuin commented Jun 13, 2019

https://github.com/terraform-aws-modules/terraform-aws-vpc/releases/tag/v2.6.0 was released this morning, so you might want to update the example.

@mathuin
Copy link

mathuin commented Jun 13, 2019

Also, possibly an unfair ask, but #338 adds some very useful functionality to v0.11 that would be super helpful in v0.12.

@nauxliu
Copy link
Contributor Author

nauxliu commented Jun 14, 2019

Also, possibly an unfair ask, but #338 adds some very useful functionality to v0.11 that would be super helpful in v0.12.

@mathuin #338 already merged, there is nothing left to do.

CHANGELOG.md Outdated
@@ -18,6 +18,8 @@ project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- Finally, Terraform 0.12 support (by @alex-goncharov @nauxliu @timboven)
- All the xx_count variables have been removed (by @nauxliu)
Copy link
Contributor

Choose a reason for hiding this comment

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

💙

@@ -1,4 +1,5 @@
data "aws_region" "current" {}
data "aws_region" "current" {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does terraform fmt in 0.12 make this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

terraform 0.12upgrade does

Copy link
Contributor

Choose a reason for hiding this comment

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

terraform fmt for 0.12.2 appears to be satisfied with either syntax. terraform -0.12upgrade has some unexpected opinions, like ending each file with a double line break, which terraform fmt also appears neutral on.

@max-rocket-internet
Copy link
Contributor

Some travis config is broken I think as it says build passed but the log is full of errors

@nauxliu nauxliu closed this Jun 14, 2019
@nauxliu nauxliu reopened this Jun 14, 2019
@nauxliu nauxliu changed the title [WIP] Upgrade to terraform 0.12 Upgrade to terraform 0.12 Jun 14, 2019
@nauxliu
Copy link
Contributor Author

nauxliu commented Jun 14, 2019

Some travis config is broken I think as it says build passed but the log is full of errors

@max-rocket-internet Fixed, Ready for review.

Copy link
Contributor

@max-rocket-internet max-rocket-internet left a comment

Choose a reason for hiding this comment

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

Works for me!

@max-rocket-internet
Copy link
Contributor

Thanks @nauxliu 🎉

It re-ordered the tags on all my resources but that was all. I'm using one worker_groups_launch_template worker group and one worker_groups_launch_template_mixed.

Let's get some more people to test before merging though.

@mcornick
Copy link

Tested, works - like @max-rocket-internet I saw some reordering of tags, but nothing destructive. I was previously using the alex-goncharov fork.

@mathuin
Copy link

mathuin commented Jun 14, 2019

Fair warning: I'm a newbie when it comes to terraform.

I'm getting some errors here in some recently-inherited code with this fork:

Error: Unsupported argument

  on main.tf line 143, in module "eks":
 143:   worker_group_launch_template_count   = "1"

An argument named "worker_group_launch_template_count" is not expected here.


Error: Unsupported argument

  on main.tf line 144, in module "eks":
 144:   worker_group_count                   = "0"

An argument named "worker_group_count" is not expected here.

Those two lines are in the module declaration, and appear to be the dreaded xx_count variables which were stripped out. While I accept that they're not desirable, some kind of documentation explaining how to fix code containing them would be desirable. They also still appear in the spot instance docs, so those might need some kind of change as well.

@nauxliu
Copy link
Contributor Author

nauxliu commented Jun 15, 2019

@mathuin The upgrade guide has been added to the issue description.

@nauxliu
Copy link
Contributor Author

nauxliu commented Jun 15, 2019

@mathuin @max-rocket-internet @markcornick
I've made two more breaking changes, Could you test again?

@sc250024
Copy link
Contributor

Thanks @nauxliu for taking care of this!

@alex-goncharov
Copy link

Thans @nauxliu, works for me.

@cawilliamson
Copy link

@nauxliu This is a little off-topic but is there any simple way I can use this in my existing code right now?

I tried with source = "github.com/nauxliu/terraform-aws-eks.git?ref=feature/0.12" but it looks like TF chokes when you have a branch containing '/'.

@endorama
Copy link

@cawilliamson this code works for me:

module "ci-cluster" {
  # source  = "terraform-aws-modules/eks/aws"
  # version = "4.0.2"
  source = "git::https://github.com/nauxliu/terraform-aws-eks.git?ref=feature/0.12"
  
  [...]
}

Ensure you commented out the version if any :) First time I tried I just changed source, without removing version and terraform was complaining.

@mathuin
Copy link

mathuin commented Jun 17, 2019

@nauxliu Everything appears to be working!

@rbayliss
Copy link

This branch worked perfectly for met to spin up a new cluster. I didn't exercise all of the different options, but the basic use case is definitely working.

@endorama
Copy link

I can confirm it's working here too!

@nauxliu nice work!

@krjackso
Copy link

Used this branch to upgrade to Terraform 0.12, felt some uneasiness over these lines in the plan:

module.k8s1.module.eks_cluster.local_file.config_map_aws_auth[0] must be replaced
module.k8s1.module.eks_cluster.null_resource.update_config_map_aws_auth[0] must be replaced

But everything worked out okay.

@max-rocket-internet
Copy link
Contributor

felt some uneasiness over these lines in the plan:
module.k8s1.module.eks_cluster.local_file.config_map_aws_auth[0] must be replaced
module.k8s1.module.eks_cluster.null_resource.update_config_map_aws_auth[0] must be replaced

I think this is OK. I have these in version control and the contents didn't actually change.

@max-rocket-internet
Copy link
Contributor

OK I've done one more test and it looks good to me. I'll merge 🚀

@max-rocket-internet max-rocket-internet merged commit da2c78b into terraform-aws-modules:master Jun 19, 2019
@kristofmartens
Copy link

Keep in mind this is a breaking change, not a big fan of forcing everybody to terraform 0.12 as not everybody can easily update to this version

@github-actions
Copy link

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 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add Terraform 0.12 support