-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Add protocol_version to lb_target_group #17260
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,20 @@ func resourceAwsLbTargetGroup() *schema.Resource { | |
ValidateFunc: validation.StringInSlice(elbv2.ProtocolEnum_Values(), true), | ||
}, | ||
|
||
"protocol_version": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
StateFunc: func(v interface{}) string { | ||
return strings.ToUpper(v.(string)) | ||
}, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
"HTTP1", | ||
"HTTP2", | ||
"GRPC", | ||
}, true), | ||
}, | ||
|
||
"vpc_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
|
@@ -294,6 +308,10 @@ func resourceAwsLbTargetGroupCreate(d *schema.ResourceData, meta interface{}) er | |
} | ||
params.Port = aws.Int64(int64(d.Get("port").(int))) | ||
params.Protocol = aws.String(d.Get("protocol").(string)) | ||
switch d.Get("protocol").(string) { | ||
case elbv2.ProtocolEnumHttp, elbv2.ProtocolEnumHttps: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. I forget sometimes when I'm deep in what I'm doing though. |
||
params.ProtocolVersion = aws.String(d.Get("protocol_version").(string)) | ||
} | ||
params.VpcId = aws.String(d.Get("vpc_id").(string)) | ||
} | ||
|
||
|
@@ -632,6 +650,10 @@ func flattenAwsLbTargetGroupResource(d *schema.ResourceData, meta interface{}, t | |
d.Set("port", targetGroup.Port) | ||
d.Set("protocol", targetGroup.Protocol) | ||
} | ||
switch d.Get("protocol").(string) { | ||
case elbv2.ProtocolEnumHttp, elbv2.ProtocolEnumHttps: | ||
d.Set("protocol_version", targetGroup.ProtocolVersion) | ||
} | ||
|
||
if err := d.Set("health_check", []interface{}{healthCheck}); err != nil { | ||
return fmt.Errorf("error setting health_check: %s", err) | ||
|
@@ -727,7 +749,7 @@ func flattenAwsLbTargetGroupStickiness(d *schema.ResourceData, attributes []*elb | |
func resourceAwsLbTargetGroupCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, v interface{}) error { | ||
protocol := diff.Get("protocol").(string) | ||
|
||
// Network Load Balancers have many special qwirks to them. | ||
// Network Load Balancers have many special quirks to them. | ||
// See http://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_CreateTargetGroup.html | ||
if healthChecks := diff.Get("health_check").([]interface{}); len(healthChecks) == 1 { | ||
healthCheck := healthChecks[0].(map[string]interface{}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! I've heard from a friend that it's really bad to add an attribute to the resource but not the data source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I almost missed it.