-
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
resource/networkmanager_vpn_attachment and update attachment_accepter #27387
resource/networkmanager_vpn_attachment and update attachment_accepter #27387
Conversation
Community NoteVoting for Prioritization
For Submitters
|
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.
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! 😃
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.
LGTM with some minor changes!
"arn": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, |
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.
It looks like id
should also be used, example here: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/networkmanager_vpc_attachment#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.
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
@@ -2,6 +2,7 @@ package networkmanager | |||
|
|||
import ( | |||
"context" | |||
"log" |
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.
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, |
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 you should use ImportStatePassthroughContext
https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.0/helper/schema#ImportStatePassthroughContext
The ImportStatePassthrough
seems to be deprecated
https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.0/helper/schema#ImportStatePassthrough
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'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
return diag.Errorf("reading Network Manager VPC Attachment (%s): %s", d.Id(), err) | ||
} | ||
|
||
a := vpcAttachment.Attachment |
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.
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.
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 would you do that change as the a
is of different type in both cases?
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.
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)
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.
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
@juhala-aws Thanks for the contribution 🎉 👏. |
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! |
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. |
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