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

Migrating to new org and terraform registry #1

Merged
merged 8 commits into from
Oct 20, 2017
Merged

Migrating to new org and terraform registry #1

merged 8 commits into from
Oct 20, 2017

Conversation

brandonjbjelland
Copy link
Contributor

Many small improvements made for this move and release:

Added

  • moved data sources to dedicated data.tf file.
  • aws_caller_identity now used to gather account_id rather than using a variable.
  • tests added for target_group and expanded for alb.

Changed

  • altered structure of module to conform to the new Terraform registry standards
  • principle_account_id (sp) moved to a data source rather than variable map. Spelling corrected.
  • removed redundant /test/alb directory which had module contents copied. Test kitchen now uses the module itself.
  • pinned examples to provider and terraform versions to harden versioning.
  • self signed cert added to the test fixtures, eliminating the need for manual upload and terraform.tfvars configuration of ssl cert arn.

@brandonjbjelland
Copy link
Contributor Author

Bumping the review here. I've still yet to test pulling this from the terraform registry (can't do that until it's published here and updated there) and I'm eager to test that functionality and make sure it aligns with the docs included.

@brandonjbjelland
Copy link
Contributor Author

brandonjbjelland commented Oct 10, 2017

Bumping once more, hoping for review here. I have tests working elsewhere and would like to get it in this repo under that model as well but can't do that until this is merged in. @antonbabenko

README.md Outdated
* Internal IP ALBs
* External IP ALBs

It's recommended you use this module with
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, I feel like it's a distinct and different task to alter all examples/tests to leverage the terraform registry modules. I'll do the work here but we should really strive for incremental changes where possible going forward.

README.md Outdated
documentation](https://aws.amazon.com/elasticloadbalancing/applicationloadbalancer/).
For an example of using ALB with ECS look no further than the [hashicorp example](https://github.com/terraform-providers/terraform-provider-aws/blob/master/examples/ecs-alb).

## Input Variables
Copy link
Member

Choose a reason for hiding this comment

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

Terraform registry is parsing variables defined in *.tf files, so there is no need to put it here and remember to update it every time when something is changed in them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove. Thanks!

README.md Outdated
* `tags` - A mapping of tags to assign to the resource.

## Outputs
* `alb_id` - `id` of the ALB created.
Copy link
Member

Choose a reason for hiding this comment

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

Same for outputs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

README.md Outdated
log_bucket = "${var.log_bucket}"
log_prefix = "${var.log_prefix}"
subnets = "${var.public_subnets}"
vpc_id = "${var.vpc_id}"
Copy link
Member

Choose a reason for hiding this comment

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

I usually put the highest-impact attributes at the top. In this case vpc_id and subnets at the most required.

Use complete values instead of references to data sources, var, other resources. This example should show exactly what is expected, but not how you will pass it into.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

}
```
3. Always `terraform plan` to see your change before running `terraform apply`.
4. Win the day!
Copy link
Member

Choose a reason for hiding this comment

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

Will do tomorrow! :)

}

provider "template" {
version = "1.0.0"
Copy link
Member

Choose a reason for hiding this comment

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

Do you actually need a specific version?

Copy link
Member

Choose a reason for hiding this comment

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

Make sure it works with the latest stable version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again moved to optimistic. Version constraints are important and will only become more important moving forward. I would only feel comfortable unsetting this if the module were actually tested against those previous versions.

}

module "sg_https_web" {
source = "github.com/terraform-community-modules/tf_aws_sg//sg_https_only"
Copy link
Member

Choose a reason for hiding this comment

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

Use new repo for security group

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
}

module "vpc" {
Copy link
Member

Choose a reason for hiding this comment

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

Can you rely on default VPC which is already created? I use it in other examples and I think it will work for your example too.

Copy link
Contributor Author

@brandonjbjelland brandonjbjelland Oct 12, 2017

Choose a reason for hiding this comment

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

I'd prefer to bring with my module an example that creates everything it needs. That way it's self-sufficient. Some default resources are inherently insecure (e.g. security groups) and I don't think it's a good idea to rely on them being in any particular state or existing at all especially since this is core to the test suite.

I'll be migrating this to the registry VPC module instead.

@@ -0,0 +1,60 @@
require 'awspec'
puts $:
Copy link
Member

Choose a reason for hiding this comment

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

What does this do? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've deleted the puts. It was debugging info.

variables.tf Outdated
type = "list"
}

variable "aws_region" {
Copy link
Member

Choose a reason for hiding this comment

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

Should not be possible to customize in the module itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unsure what's meant by this. Can you explain?

variables.tf Outdated

variable "alb_security_groups" {
description = "A comma separated string of security groups with which we associate the ALB. e.g. 'sg-edcd9784,sg-edcd9785'"
type = "list"
Copy link
Member

Choose a reason for hiding this comment

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

So, list or string. Update description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

variables.tf Outdated

variable "alb_name" {
description = "The name of the ALB as will show in the AWS EC2 ELB console."
default = "my-alb"
Copy link
Member

Choose a reason for hiding this comment

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

Don't make defaults for critical things like name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

variables.tf Outdated
*/

variable "alb_is_internal" {
description = "Determines if the ALB is internal. Default: false"
Copy link
Member

Choose a reason for hiding this comment

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

Usually there is o need to write what is the default value, because it is visible 1 line below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed where relevant.

variables.tf Outdated
}

variable "alb_protocols" {
description = "A comma delimited list of the protocols the ALB accepts. e.g.: HTTPS"
Copy link
Member

Choose a reason for hiding this comment

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

Can you make it to accept list natively and join to string, if resource expect string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.


variable "backend_port" {
description = "The port the service on the EC2 instances listen on."
default = 80
Copy link
Member

Choose a reason for hiding this comment

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

No assumption. Make it fail, if user put bad value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again here, providing a default of what many if not most people would use (and a collection of defaults that work together) is not a bad approach. Following "make no assumptions " to a logical conclusion leaves a module consumer requiring to specify every last variable which strips some of the value of modules. Modules are intended to enable people to get started quickly with bundled resources. Part of that is adding defaults that are likely to fit many use cases.


variable "backend_protocol" {
description = "The protocol the backend service speaks. Options: HTTP, HTTPS, TCP, SSL (secure tcp)."
default = "HTTP"
Copy link
Member

Choose a reason for hiding this comment

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

Same here, don't use default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't completely follow the logic of not providing any defaults... sane and often used defaults are a good thing to offer as they are in part what adds value to modules. If literally every variable is stripped of defaults, the result is a module that is pretty well as long as specifying all the components by hand without a module.

Can you make a better case for not providing defaults like this?

variables.tf Outdated
}

variable "cookie_duration" {
description = "If load balancer connection stickiness is desired, set this to the duration that cookie should be valid. If no stickiness is wanted, leave it blank. e.g.: 300"
Copy link
Member

Choose a reason for hiding this comment

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

blank, eg: 300. So what?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An example value that would work is "300". I've clarified the description.

variables.tf Outdated

variable "health_check_path" {
description = "The URL the ELB should use for health checks. e.g. /health"
default = "/"
Copy link
Member

Choose a reason for hiding this comment

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

no default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -0,0 +1,24 @@
output "alb_id" {
Copy link
Member

Choose a reason for hiding this comment

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

Put all outputs available from Terraform along with description which comes from documentation page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what's meant by this. All outputs have descriptions and values. Can you clarify?

@antonbabenko
Copy link
Member

Sorry for the delay in response.

@brandonjbjelland
Copy link
Contributor Author

brandonjbjelland commented Oct 12, 2017

All feedback addressed locally and I'll push up the branch in the next couple hours. A few questions to your comments are above.

In the spirit of fairness I need a couple things if I'm going to keep maintaining the repo within this org:

  1. I want to be listed as the maintainer of this project on the terraform registry. If that means we need to delete and resubmit alb or transfer ownership, let's do that. I started the project, have grown it, and I would like credit as its primary maintainer.
  2. I need the ability to publish changes here (to github) and not be blocked by review just as you're not blocked on your repos. Probably just a permissions oversight. It doesn't really make sense for the primary maintainer (me) to not be allowed to actually own the repo and control its direction.

I hope you can agree and make those adjustments. I would guess were likely just wanting to get naming right and consistent for this set of AWS modules and that you're striving for quality, but it's only fair for me to be credited with my work and have the ability to continue it as the maintainer. Sound good? 🤝

@antonbabenko
Copy link
Member

@brandoconnor I respect your contributions, ownership and completely agree with all you are saying. Also, small iterations are important, and we needed to make it fit the registry standards. This was mostly what I was trying to comment about. I will do my review during today and you can merge it when you want and publish to the registry.

After that let's review each other code as normal.

README.md Outdated
[terraform-aws-security-group](https://registry.terraform.io/modules/terraform-aws-modules/security-group/aws), and
[terraform-aws-autoscaling](https://registry.terraform.io/modules/terraform-aws-modules/autoscaling/aws/).

## Why ALB instad of ELB?
Copy link
Member

Choose a reason for hiding this comment

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

"instead"

locals.tf Outdated
@@ -0,0 +1,18 @@
locals {
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be generated using data-source, or load from template file (similar to how you do with certificates) to be more consistent throught the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you find a doc or the source code for it? I looked but didn't see it.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm so that's what I looked at but I thought an IAM policy was distinct from an S3 bucket policy. Turns out, they are different (S3 contains a principal and IAM doesn't) however that's an argument for this resource. That's all to say, if this can be used to generate more than IAM policy, it's probably badly named.

Will fix tonight.

Copy link
Member

Choose a reason for hiding this comment

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

I had exactly the same feeling when I first discovered that data source.

@brandonjbjelland brandonjbjelland self-assigned this Oct 20, 2017
@brandonjbjelland brandonjbjelland merged commit b5a4c76 into terraform-aws-modules:master Oct 20, 2017
@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 17, 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.

2 participants