-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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 #2173
New Resource: aws_dx_connection #2173
Conversation
atsushi-ishibashi
commented
Nov 4, 2017
After this PR and #2154 will be merged, I'll develop |
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 for this PR @atsushi-ishibashi
I left you some comments there. Let me know if anything's unclear.
Also I assume you'll need to rebase the branch since your other DX PR was just merged and conflicts with this one.
aws/resource_aws_dx_connection.go
Outdated
Required: true, | ||
ForceNew: true, | ||
}, | ||
"band_width": &schema.Schema{ |
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 I never saw this spelled as "band width" and the API also uses 1 word - bandwidth - mind changing that?
aws/resource_aws_dx_connection.go
Outdated
} | ||
resp, err := conn.DescribeConnections(input) | ||
if err != nil { | ||
d.SetId("") |
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 mentioned in your other DX PR - we shouldn't remove a resource from the state on any error and there's no relevant error that would signal missing resource: http://docs.aws.amazon.com/directconnect/latest/APIReference/API_DescribeConnections.html#API_DescribeConnections_Errors
aws/resource_aws_dx_connection.go
Outdated
return err | ||
} | ||
if len(resp.Connections) != 1 { | ||
d.SetId("") |
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.
Same here - we should only ever remove the resource from state if len(resp.Connections) < 1
(and not error out in such case).
aws/resource_aws_dx_connection.go
Outdated
return fmt.Errorf("[ERROR] Number of DX Connection (%s) isn't one, got %d", connectionId, len(resp.Connections)) | ||
} | ||
if d.Id() != *resp.Connections[0].ConnectionId { | ||
d.SetId("") |
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.
Same here ^
aws/resource_aws_dx_connection.go
Outdated
} | ||
deleteStateConf := &resource.StateChangeConf{ | ||
Pending: []string{directconnect.ConnectionStatePending, directconnect.ConnectionStateOrdering, directconnect.ConnectionStateAvailable, directconnect.ConnectionStateRequested}, | ||
Target: []string{directconnect.ConnectionStateDeleted, directconnect.ConnectionStateDeleting}, |
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.
Any particular reason to treat directconnect.ConnectionStateDeleting
as target here?
resource "aws_dx_connection" "hoge" { | ||
name = "tf-dx-%s" | ||
band_width = "1Gbps" | ||
location = "EqDC2" |
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 mentioned in your other PR - we run all acceptance tests in us-west-2
, so we'll need to set a different location here, e.g. EqSe2
aws/validators.go
Outdated
@@ -1651,3 +1651,21 @@ func validateCognitoRoles(v map[string]interface{}, k string) (errors []error) { | |||
|
|||
return | |||
} | |||
|
|||
func validateDxConnectionBandWidth(v interface{}, k string) (ws []string, errors []error) { |
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.
How do you feel about renaming the other validation function from the previous PR and reusing it here? It seems to be validating the exact same thing.
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 validateDxConnectionBandWidth
is better name so I replace dx_lag validate func with it.
return err | ||
} | ||
for _, v := range resp.Connections { | ||
if *v.ConnectionId == rs.Primary.ID && !(*v.ConnectionState == directconnect.ConnectionStateDeleted || *v.ConnectionState == directconnect.ConnectionStateDeleting) { |
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.
directconnect.ConnectionStateDeleting
shouldn't be treated as "gone" here, IMO
2887129
to
c7df691
Compare
c7df691
to
fd2e1a3
Compare
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'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! |