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

New Resource: aws_dx_connection #2173

Merged

Conversation

atsushi-ishibashi
Copy link
Contributor

make testacc TEST=./aws TESTARGS='-run=TestAccAwsDxConnection_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAwsDxConnection_basic -timeout 120m
=== RUN   TestAccAwsDxConnection_basic
--- PASS: TestAccAwsDxConnection_basic (64.31s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	64.364s

@atsushi-ishibashi
Copy link
Contributor Author

After this PR and #2154 will be merged, I'll develop aws_dx_lag_association to associate connection with lag.

@Ninir Ninir added the enhancement Requests to existing resources that expand the functionality or scope. label Nov 5, 2017
Copy link
Member

@radeksimko radeksimko left a 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.

Required: true,
ForceNew: true,
},
"band_width": &schema.Schema{
Copy link
Member

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?

}
resp, err := conn.DescribeConnections(input)
if err != nil {
d.SetId("")
Copy link
Member

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

return err
}
if len(resp.Connections) != 1 {
d.SetId("")
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 - we should only ever remove the resource from state if len(resp.Connections) < 1 (and not error out in such case).

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("")
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 ^

}
deleteStateConf := &resource.StateChangeConf{
Pending: []string{directconnect.ConnectionStatePending, directconnect.ConnectionStateOrdering, directconnect.ConnectionStateAvailable, directconnect.ConnectionStateRequested},
Target: []string{directconnect.ConnectionStateDeleted, directconnect.ConnectionStateDeleting},
Copy link
Member

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"
Copy link
Member

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

@@ -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) {
Copy link
Member

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.

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 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) {
Copy link
Member

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

@radeksimko radeksimko added new-resource Introduces a new resource. waiting-response Maintainers are waiting on response from community or contributor. and removed enhancement Requests to existing resources that expand the functionality or scope. labels Nov 7, 2017
@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Nov 7, 2017
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Thanks 👍 🚀

@radeksimko radeksimko merged commit 0c39144 into hashicorp:master Nov 7, 2017
@atsushi-ishibashi atsushi-ishibashi deleted the resource_dx_connection branch December 13, 2017 15:16
@ghost
Copy link

ghost commented Apr 10, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@hashicorp hashicorp locked and limited conversation to collaborators Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-resource Introduces a new resource.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants