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_lag #2154

Merged
merged 4 commits into from Nov 7, 2017

Conversation

atsushi-ishibashi
Copy link
Contributor

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

@atsushi-ishibashi
Copy link
Contributor Author

Related #876

@Ninir Ninir added the enhancement Requests to existing resources that expand the functionality or scope. label Nov 5, 2017
@radeksimko radeksimko added new-resource Introduces a new resource. and removed enhancement Requests to existing resources that expand the functionality or scope. labels 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.

Hi @atsushi-ishibashi
thanks for the PR.

I left you some comments - some are more important, some less. Let me know if you need any further clarification.

}
if len(resp.Lags) != 1 {
d.SetId("")
return fmt.Errorf("[ERROR] Number of DX Lag (%s) isn't one, got %d", lagId, len(resp.Lags))
Copy link
Member

Choose a reason for hiding this comment

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

I'm ok with erroring out if we get != 1 lags, but I don't think it's a reason for removing the LAG from state. We should only be removing it from state if it's not found - i.e. len(resp.Lags) < 1

}
resp, err := conn.DescribeLags(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.

I can't find any particular error that would mean LAG is gone in this context: http://docs.aws.amazon.com/directconnect/latest/APIReference/API_DescribeLags.html#c
so I don't think error here is a reason for removing the LAG from state. 🤔

}
if d.Id() != *resp.Lags[0].LagId {
d.SetId("")
return fmt.Errorf("[ERROR] DX Lag (%s) not found", lagId)
Copy link
Member

Choose a reason for hiding this comment

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

It makes sense to error out if wrong ID was found (not sure how/why would that happen, but strange things do happen sometimes), but I'm not sure if it's the reason for removing LAG from state.

}
deleteStateConf := &resource.StateChangeConf{
Pending: []string{directconnect.LagStateAvailable, directconnect.LagStateRequested, directconnect.LagStatePending},
Target: []string{directconnect.LagStateDeleted, directconnect.LagStateDeleting},
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason we should treat directconnect.LagStateDeleting as Target state here?

Type: schema.TypeString,
Required: 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 is there any reason to drift away from the name in the API? i.e. can't we just call it connections_bandwidth?

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 totally agree with your reviews!

Required: true,
ForceNew: true,
},
"num_connections": &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 is there any reason to drift away from the name in the API? i.e. can't we just call it number_of_connections ?

resource "aws_dx_lag" "hoge" {
name = "tf-dx-lag-%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.

Do you mind changing the location to a one which is available in us-west-2 as all of our tests run in that region? e.g. EqSe2

@radeksimko radeksimko added the waiting-response Maintainers are waiting on response from community or contributor. label 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.

Just one last thing before we can merge this.
Thanks for implementing all the changes!

}
if len(resp.Lags) != 1 {
if len(resp.Lags) < 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.

I think in this case (when Lag was removed) we don't want to error out - at least it's a convention not to do that.

Also - which is rather a nitpick - we can move this condition above or below the other condition and avoid the nesting & indentation so it's easier to read.

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 understood the convention 🙇

@radeksimko radeksimko merged commit 58def39 into hashicorp:master Nov 7, 2017
@atsushi-ishibashi atsushi-ishibashi deleted the resource_aws_dx_lag 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