-
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
New Resource: aws_dx_connection_association #2360
New Resource: aws_dx_connection_association #2360
Conversation
atsushi-ishibashi
commented
Nov 18, 2017
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.
@atsushi-ishibashi Thanks for another PR!
This looks overall good, I just left you some questions. Please keep in mind those are questions - I am not implying that it should be one way or another, I'm opening a conversation. 😉
d.SetId("") | ||
return nil | ||
} | ||
if *resp.Connections[0].LagId != d.Get("lag_id").(string) { |
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.
As far as I understand there's 1-to-1 relationship between a connection and a LAG which this resource should represent, so shouldn't we instead treat this as if the resource (i.e. unique pair) is gone?
return nil | ||
} | ||
if len(resp.Connections) != 1 { | ||
return fmt.Errorf("Number of DX Connection (%s) isn't one, got %d", connectionId, len(resp.Connections)) |
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.
Just grammar nitpick - do you mind changing this to Found %d DX connections for %s, expected 1
?
if err != nil { | ||
return err | ||
} | ||
if resp.LagId != nil { |
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.
Have you ever experienced this in reality? Is it just a matter of time until it becomes actually disassociated or is it an erroneous/unrecoverable state? If it's the former then I'd suggest we just put a retry logic in place and wait until it's disassociated. If it's the latter then I guess this is a correct behaviour - I'm just trying to ensure that we know what we're doing here.
page_title: "AWS: aws_dx_connection_association" | ||
sidebar_current: "docs-aws-resource-dx-connection-association" | ||
description: |- | ||
Associates a Connection with LAG. |
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.
Nitpick, but do you mind changing this to Associates a Direct Connect Connection with a LAG.
?
|
||
# aws_dx_connection_association | ||
|
||
Associates a Connection with LAG. |
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.
Nitpick, but do you mind changing this to Associates a Direct Connect Connection with a LAG.
?
I removed some extra error handling. |
if len(resp.Connections) < 1 { | ||
d.SetId("") | ||
return nil | ||
} |
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.
I think there was a bit of misunderstanding about what I meant by my question about LAG ID mismatch - I wasn't implying it should be removed. I meant we should treat it the same way as if there is no connection - i.e. d.SetId(""); return nil
.
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.
Oh, I got it👍
} | ||
for _, v := range resp.Connections { | ||
if *v.ConnectionId == rs.Primary.ID && v.LagId != nil { | ||
return fmt.Errorf("Dx Connection (%s) is not diasociated with Lag", rs.Primary.ID) |
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.
nitpick: is not dissociated from Lag
So I took a deeper look into how Direct Connect works with LAGs & connections and I think we'll need to add a for loop to read through all connections for the given connection ID as we cannot assume that there's only 1 connection per lag. Basically we need to make the following config work: resource "aws_dx_connection" "example" {
name = "example"
bandwidth = "1Gbps"
location = "EqSe2"
}
resource "aws_dx_lag" "example" {
name = "example"
connections_bandwidth = "1Gbps"
location = "EqSe2"
number_of_connections = 1
}
resource "aws_dx_lag" "example2" {
name = "example2"
connections_bandwidth = "1Gbps"
location = "EqSe2"
number_of_connections = 1
}
resource "aws_dx_connection_association" "example" {
connection_id = "${aws_dx_connection.example.id}"
lag_id = "${aws_dx_lag.example.id}"
}
resource "aws_dx_connection_association" "example2" {
connection_id = "${aws_dx_connection.example.id}"
lag_id = "${aws_dx_lag.example2.id}"
} can you also add it as an acceptance test and make it pass, please? |
Could I understand what you meant? @radeksimko
|
Having a test for multiple connections is certainly helpful (thanks 👍 ), but I was talking about multiple LAGs. I just committed a failing test to you branch which hopefully explains what I mean. You should see the following failure:
Let me know if you need any further help in reproducing it. |
@radeksimko |
@atsushi-ishibashi I see, thanks for the explanation. It looks like the AWS API is behaving unexpectedly in the sense that it just accepts any association and overrides the existing one. 😞 I assume there isn't much we can do in this case - other than ask AWS to change/fix the API. I'll merge it as is then - after removing my test. |
c0fc1fe
to
53df933
Compare
* New Resource: aws_dx_connection_association * Reflect reviews * fix * fix * Reflect 2nd reviews * Add acctest
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |