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

resource/networkmanager_vpn_attachment and update attachment_accepter #27387

Merged
merged 25 commits into from
Nov 10, 2022

Conversation

juhala-aws
Copy link
Contributor

@juhala-aws juhala-aws commented Oct 21, 2022

Description

Adds new Network Manager VPN Attachment resource and updates logic in Attachment Accepter. Previously Attachment Accepter only worked with VPC attachments. These changes are tightly related to each other as attachment accepter depends on functions in VPN attachment.

Relations

Relates #26420
Relates #25835
Depends #27693
Closes #27544.

References

CreateSiteToSiteVpnAttachment

Output from Acceptance Testing

-> % make testacc PKG=networkmanager TESTS=TestAccNetworkManagerVpnAttachment_basic
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/networkmanager/... -v -count 1 -parallel 20 -run='TestAccNetworkManagerVpnAttachment_basic'  -timeout 180m
=== RUN   TestAccNetworkManagerVpnAttachment_basic
=== PAUSE TestAccNetworkManagerVpnAttachment_basic
=== CONT  TestAccNetworkManagerVpnAttachment_basic
--- PASS: TestAccNetworkManagerVpnAttachment_basic (1632.24s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/networkmanager     1636.750s


-> % make testacc PKG=networkmanager TESTS=TestAccNetworkManagerVpnAttachment_disappears
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/networkmanager/... -v -count 1 -parallel 20 -run='TestAccNetworkManagerVpnAttachment_disappears'  -timeout 180m
=== RUN   TestAccNetworkManagerVpnAttachment_disappears
=== PAUSE TestAccNetworkManagerVpnAttachment_disappears
=== CONT  TestAccNetworkManagerVpnAttachment_disappears
--- PASS: TestAccNetworkManagerVpnAttachment_disappears (1625.69s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/networkmanager     1630.283s


-> % make testacc PKG=networkmanager TESTS=TestAccNetworkManagerVpnAttachment_tags
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/networkmanager/... -v -count 1 -parallel 20 -run='TestAccNetworkManagerVpnAttachment_tags'  -timeout 180m
=== RUN   TestAccNetworkManagerVpnAttachment_tags
=== PAUSE TestAccNetworkManagerVpnAttachment_tags
=== CONT  TestAccNetworkManagerVpnAttachment_tags
--- PASS: TestAccNetworkManagerVpnAttachment_tags (1721.17s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/networkmanager     1725.774s

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. service/networkmanager Issues and PRs that pertain to the networkmanager service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. labels Oct 21, 2022
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @juhala-aws 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

Copy link
Contributor

@schuylr schuylr left a comment

Choose a reason for hiding this comment

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

LGTM with some minor changes!

internal/service/networkmanager/attachment_accepter.go Outdated Show resolved Hide resolved
internal/service/networkmanager/attachment_accepter.go Outdated Show resolved Hide resolved
internal/service/networkmanager/attachment_accepter.go Outdated Show resolved Hide resolved
internal/service/networkmanager/attachment_accepter.go Outdated Show resolved Hide resolved
internal/service/networkmanager/attachment_accepter.go Outdated Show resolved Hide resolved
internal/service/networkmanager/attachment_accepter.go Outdated Show resolved Hide resolved
internal/service/networkmanager/vpn_attachment.go Outdated Show resolved Hide resolved
internal/service/networkmanager/vpn_attachment.go Outdated Show resolved Hide resolved
"arn": {
Type: schema.TypeString,
Computed: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@yfauser yfauser left a comment

Choose a reason for hiding this comment

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

That's a lot of great work in there @juhala-aws ! I left a couple of comments. Also, you still need to add the changelog file in .changelog

internal/service/networkmanager/vpn_attachment.go Outdated Show resolved Hide resolved
@@ -2,6 +2,7 @@ package networkmanager

import (
"context"
"log"
Copy link
Contributor

Choose a reason for hiding this comment

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

You might have to review the way you do logging (https://developer.hashicorp.com/terraform/plugin/log/writing). That's dependent on the SDK version

DeleteWithoutTimeout: resourceVpnAttachmentDelete,

Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
Copy link
Contributor

Choose a reason for hiding this comment

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

internal/service/networkmanager/vpn_attachment.go Outdated Show resolved Hide resolved
internal/service/networkmanager/vpn_attachment.go Outdated Show resolved Hide resolved
website/docs/r/networkmanager_vpn_attachment.html.markdown Outdated Show resolved Hide resolved
Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

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

I've added some comments to the PR. The resource type will also need to be registered with the provider in the file internal/provider/provider.go

internal/service/networkmanager/attachment_accepter.go Outdated Show resolved Hide resolved
internal/service/networkmanager/attachment_accepter.go Outdated Show resolved Hide resolved
return diag.Errorf("reading Network Manager VPC Attachment (%s): %s", d.Id(), err)
}

a := vpcAttachment.Attachment
Copy link
Contributor

Choose a reason for hiding this comment

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

In both cases, a is being set to the *networkmanager.Attachment returned and then the same values are being set on the resource. Instead of duplicating the code for each case, a could be retrieved using the Find... function, and a could be handled once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would you do that change as the a is of different type in both cases?

Copy link
Contributor

Choose a reason for hiding this comment

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

In both cases, a is a *networkmanager.Attachment, so you could declare a before he switch statement, set the value in the switch statement, and then read the values after the switch.

Something like:

var a *networkmanager.Attachment
switch aType := d.Get("attachment_type"); aType {
  case "VPC":
    ...
    a = vpcAttachment.Attachment
 case  "SITE_TO_SITE_VPN":
    ...
    a = vpnAttachment.Attachment
}

d.Set("a_b_c", a.ABC)
...
d.Set("x_y_z", a.XYZ)

internal/service/networkmanager/vpn_attachment.go Outdated Show resolved Hide resolved
internal/service/networkmanager/vpn_attachment.go Outdated Show resolved Hide resolved
internal/service/networkmanager/vpn_attachment.go Outdated Show resolved Hide resolved
internal/service/networkmanager/vpn_attachment.go Outdated Show resolved Hide resolved
internal/service/networkmanager/vpn_attachment.go Outdated Show resolved Hide resolved
internal/service/networkmanager/vpn_attachment.go Outdated Show resolved Hide resolved
internal/service/networkmanager/vpn_attachment_test.go Outdated Show resolved Hide resolved
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Nov 1, 2022
@github-actions github-actions bot added the provider Pertains to the provider itself, rather than any interaction with AWS. label Nov 8, 2022
@juhala-aws juhala-aws marked this pull request as ready for review November 10, 2022 08:01
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccNetworkManagerSiteToSiteVPNAttachment_' PKG=networkmanager ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/networkmanager/... -v -count 1 -parallel 2  -run=TestAccNetworkManagerSiteToSiteVPNAttachment_ -timeout 180m
=== RUN   TestAccNetworkManagerSiteToSiteVPNAttachment_basic
=== PAUSE TestAccNetworkManagerSiteToSiteVPNAttachment_basic
=== RUN   TestAccNetworkManagerSiteToSiteVPNAttachment_disappears
=== PAUSE TestAccNetworkManagerSiteToSiteVPNAttachment_disappears
=== RUN   TestAccNetworkManagerSiteToSiteVPNAttachment_tags
=== PAUSE TestAccNetworkManagerSiteToSiteVPNAttachment_tags
=== CONT  TestAccNetworkManagerSiteToSiteVPNAttachment_basic
=== CONT  TestAccNetworkManagerSiteToSiteVPNAttachment_tags
--- PASS: TestAccNetworkManagerSiteToSiteVPNAttachment_tags (1181.63s)
=== CONT  TestAccNetworkManagerSiteToSiteVPNAttachment_disappears
--- PASS: TestAccNetworkManagerSiteToSiteVPNAttachment_basic (1289.84s)
--- PASS: TestAccNetworkManagerSiteToSiteVPNAttachment_disappears (1508.83s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/networkmanager	2694.597s
% make testacc TESTARGS='-run=TestAccNetworkManagerVPCAttachment_' PKG=networkmanager ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/networkmanager/... -v -count 1 -parallel 2  -run=TestAccNetworkManagerVPCAttachment_ -timeout 180m
=== RUN   TestAccNetworkManagerVPCAttachment_basic
=== PAUSE TestAccNetworkManagerVPCAttachment_basic
=== RUN   TestAccNetworkManagerVPCAttachment_disappears
=== PAUSE TestAccNetworkManagerVPCAttachment_disappears
=== RUN   TestAccNetworkManagerVPCAttachment_tags
=== PAUSE TestAccNetworkManagerVPCAttachment_tags
=== RUN   TestAccNetworkManagerVPCAttachment_update
=== PAUSE TestAccNetworkManagerVPCAttachment_update
=== CONT  TestAccNetworkManagerVPCAttachment_basic
=== CONT  TestAccNetworkManagerVPCAttachment_tags
--- PASS: TestAccNetworkManagerVPCAttachment_basic (887.30s)
=== CONT  TestAccNetworkManagerVPCAttachment_update
--- PASS: TestAccNetworkManagerVPCAttachment_tags (1008.65s)
=== CONT  TestAccNetworkManagerVPCAttachment_disappears
--- PASS: TestAccNetworkManagerVPCAttachment_update (1110.56s)
--- PASS: TestAccNetworkManagerVPCAttachment_disappears (960.53s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/networkmanager	1973.655s

@ewbankkit
Copy link
Contributor

ewbankkit commented Nov 10, 2022

@juhala-aws Thanks for the contribution 🎉 👏.
In general everything was great.
I went ahead and changed the resource name to aws_networkmanager_site_to_site_vpn_attachment to match the underlying AWS API and future-proof against potentially other types of VPN attachment.

@ewbankkit ewbankkit merged commit 5a83916 into hashicorp:main Nov 10, 2022
@github-actions github-actions bot added this to the v4.39.0 milestone Nov 10, 2022
@github-actions
Copy link

This functionality has been released in v4.39.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2022
@justinretzolk justinretzolk added the partner Contribution from a partner. label May 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. partner Contribution from a partner. provider Pertains to the provider itself, rather than any interaction with AWS. service/networkmanager Issues and PRs that pertain to the networkmanager service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: CloudWAN core_network_id support for aws_vpn_connection
6 participants