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

provider/aws: Initial support for Application Load Balancers #8254

Merged
merged 4 commits into from
Aug 17, 2016

Conversation

jen20
Copy link
Contributor

@jen20 jen20 commented Aug 17, 2016

This pull request contains the first two resources for Application Load Balancers ("ALB" or "elbv2"), aws_alb and aws_alb_target_group.

The resources necessary will be split across a number of pull requests to facilitate review.

Part of #8137.

@jen20 jen20 force-pushed the f-aws-application-lb branch 2 times, most recently from 197ef40 to 0145099 Compare August 17, 2016 12:56
return fmt.Errorf("Unable to find ALB: %#v", describeResp.LoadBalancers)
}

alb := describeResp.LoadBalancers[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we guarantee that our ALB is the first in the collection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - otherwise the error above would trigger.

@jen20 jen20 force-pushed the f-aws-application-lb branch from 0145099 to db22a82 Compare August 17, 2016 13:00
return err
}

log.Printf("[INFO] ALB ID: %s", d.Id())
Copy link
Contributor

Choose a reason for hiding this comment

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

You are using d.Id before setting it below

@jen20 jen20 force-pushed the f-aws-application-lb branch 2 times, most recently from 697869f to da4f09c Compare August 17, 2016 13:17
},

"security_groups": {
Type: schema.TypeSet,
Copy link
Contributor

Choose a reason for hiding this comment

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

If this cannot be modified, then this should be ForceNew: true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, corrected.

@jen20 jen20 force-pushed the f-aws-application-lb branch from da4f09c to 9ea782b Compare August 17, 2016 13:22

func validateAwsAlbTargetGroupPort(v interface{}, k string) (ws []string, errors []error) {
port := v.(int)
if port < 0 || port > 65536 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be <1 not <0

@jen20 jen20 force-pushed the f-aws-application-lb branch 6 times, most recently from b4361ce to 5276d21 Compare August 17, 2016 13:39

log.Printf("[DEBUG] ALB create configuration: %#v", elbOpts)
var albArn string
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
Copy link
Member

Choose a reason for hiding this comment

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

Why exactly are we retrying this operation if there's no RetryableError?

@jen20 jen20 force-pushed the f-aws-application-lb branch from 5276d21 to 6619bc2 Compare August 17, 2016 13:54
}

accessLogMap := map[string]interface{}{}
for _, attr := range attributesResp.Attributes {
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't this be easier to maintain going forward if we just had a single attributes (TypeMap) field instead of trying to do this conversion?

Admittedly we'd probably still need to have some kind of key-filtering because of #8104

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 think we can easily do that and retain the same semantics? Here we construct the required structure to set on access_log - the other attributes work on different prefixes? We could have a single attributes map in the schema, but I think this is more explicit and closer to expectations at the moment.

Copy link
Member

Choose a reason for hiding this comment

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

the other attributes work on different prefixes

yeah, it would mean making the map keys more verbose, which goes against UX, so forget what I said. This looks 👌

@jen20 jen20 force-pushed the f-aws-application-lb branch from 6619bc2 to 3d83c41 Compare August 17, 2016 14:24
@radeksimko
Copy link
Member

radeksimko commented Aug 17, 2016

@jen20 This is looking pretty good.


I tried running the attached acceptance tests and one failed:

TF_ACC=1 go test ./builtin/providers/aws -v -run=AccAWSALB -timeout 120m
=== RUN   TestAccAWSALBTargetGroup_basic
--- PASS: TestAccAWSALBTargetGroup_basic (34.37s)
=== RUN   TestAccAWSALBTargetGroup_updateHealthCheck
--- PASS: TestAccAWSALBTargetGroup_updateHealthCheck (53.44s)
=== RUN   TestAccAWSALB_basic
--- PASS: TestAccAWSALB_basic (46.35s)
=== RUN   TestAccAWSALB_accesslogs
--- FAIL: TestAccAWSALB_accesslogs (53.77s)
        testing.go:265: Step 1 error: Error applying: 1 error(s) occurred:

            * aws_s3_bucket.logs: Error creating S3 bucket: InvalidBucketName: The specified bucket is not valid.
                status code: 400, request id: B37F0544044DE86D
FAIL
exit status 1
FAIL    github.com/hashicorp/terraform/builtin/providers/aws    187.957s

@jen20
Copy link
Contributor Author

jen20 commented Aug 17, 2016

@radeksimko Yup, fixing that up at the moment.

jen20 added 2 commits August 17, 2016 15:48
This commit adds a resource, acceptance tests and documentation for the
new Application Load Balancer (aws_alb). We choose to use the name alb
over the package name, elbv2, in order to avoid confusion.

This is the first in a series of commits to fully support the new
resources necessary for Application Load Balancers.
This commit adds a resource, acceptance tests and documentation for the
Target Groups for Application Load Balancers.

This is the second in a series of commits to fully support the new
resources necessary for Application Load Balancers.
@jen20 jen20 force-pushed the f-aws-application-lb branch from 3d83c41 to 531a976 Compare August 17, 2016 14:48
@jen20
Copy link
Contributor Author

jen20 commented Aug 17, 2016

› envchain aws.terraform make testacc TEST=./builtin/providers/aws TESTARGS="-run TestAccAWSALB"
==> Checking that code complies with gofmt requirements...
/Users/James/Code/go/bin/stringer
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/08/17 15:54:22 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run TestAccAWSALB -timeout 120m
=== RUN   TestAccAWSALBTargetGroup_basic
--- PASS: TestAccAWSALBTargetGroup_basic (36.57s)
=== RUN   TestAccAWSALBTargetGroup_updateHealthCheck
--- PASS: TestAccAWSALBTargetGroup_updateHealthCheck (59.23s)
=== RUN   TestAccAWSALB_basic
--- PASS: TestAccAWSALB_basic (51.25s)
=== RUN   TestAccAWSALB_accesslogs
--- PASS: TestAccAWSALB_accesslogs (93.51s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    240.584s

@jen20 jen20 merged commit f5f3154 into master Aug 17, 2016
@jen20 jen20 deleted the f-aws-application-lb branch August 17, 2016 15:05
@ghost
Copy link

ghost commented Apr 23, 2020

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

@ghost ghost locked and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants