-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat: add contact_email to equinix_metal_connection datasource and resource #412
Merged
displague
merged 2 commits into
main
from
340-equinix_metal_connection-should-support-api-field-contact_email
Oct 16, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ resource "equinix_metal_connection" "example" { | |
metro = "sv" | ||
speed = "1000Mbps" | ||
service_token_type = "a_side" | ||
contact_email = "[email protected]" | ||
} | ||
|
||
data "equinix_ecx_l2_sellerprofile" "example" { | ||
|
@@ -64,6 +65,7 @@ resource "equinix_metal_connection" "example" { | |
metro = "FR" | ||
speed = "200Mbps" | ||
service_token_type = "z_side" | ||
contact_email = "[email protected]" | ||
} | ||
|
||
data "equinix_ecx_port" "example" { | ||
|
@@ -92,6 +94,7 @@ resource "equinix_metal_connection" "example" { | |
metro = "SV" | ||
redundancy = "redundant" | ||
type = "shared" | ||
contact_email = "[email protected]" | ||
} | ||
|
||
data "equinix_ecx_port" "example" { | ||
|
@@ -118,6 +121,7 @@ The following arguments are supported: | |
* `facility` - (**Deprecated**) Facility where the connection will be created. Use metro instead; read the [facility to metro migration guide](https://registry.terraform.io/providers/equinix/equinix/latest/docs/guides/migration_guide_facilities_to_metros_devices) | ||
* `redundancy` - (Required) Connection redundancy - redundant or primary. | ||
* `type` - (Required) Connection type - dedicated or shared. | ||
* `contact_email` - (Required) The preferred email used for communication and notifications about the Equinix Fabric interconnection. Required when using a Project API key. Optional and defaults to the primary user email address when using a User API key. | ||
* `project_id` - (Optional) ID of the project where the connection is scoped to, must be set for. | ||
* `speed` - (Required) Connection speed - one of 50Mbps, 200Mbps, 500Mbps, 1Gbps, 2Gbps, 5Gbps, 10Gbps. | ||
* `description` - (Optional) Description for the connection resource. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,13 @@ func resourceMetalConnection() *schema.Resource { | |
string(packngo.ConnectionPrimary), | ||
}, false), | ||
}, | ||
"contact_email": { | ||
Type: schema.TypeString, | ||
Description: "The preferred email used for communication and notifications about the Equinix Fabric interconnection. Required when using a Project API key. Optional and defaults to the primary user email address when using a User API key", | ||
Optional: true, | ||
Computed: true, | ||
ForceNew: true, // TODO(displague) packngo needs updating | ||
}, | ||
"type": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
|
@@ -221,6 +228,11 @@ func resourceMetalConnectionCreate(d *schema.ResourceData, meta interface{}) err | |
Type: connType, | ||
} | ||
|
||
// missing email is tolerated for user keys (can't be reasonably detected) | ||
if contactEmail, ok := d.GetOk("contact_email"); ok { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this doesn't match the |
||
connReq.ContactEmail = contactEmail.(string) | ||
} | ||
|
||
speedRaw, speedOk := d.GetOk("speed") | ||
|
||
// missing speed is tolerated only for shared connections of type z_side | ||
|
@@ -334,6 +346,9 @@ func resourceMetalConnectionUpdate(d *schema.ResourceData, meta interface{}) err | |
ur.Redundancy = redundancy | ||
} | ||
|
||
// TODO(displague) packngo does not implement ContactEmail for update | ||
// if d.HasChange("contact_email" {} | ||
|
||
if d.HasChange("tags") { | ||
ts := d.Get("tags") | ||
sts := []string{} | ||
|
@@ -455,6 +470,7 @@ func resourceMetalConnectionRead(d *schema.ResourceData, meta interface{}) error | |
return setMap(d, map[string]interface{}{ | ||
"organization_id": conn.Organization.ID, | ||
"project_id": projectId, | ||
"contact_email": conn.ContactEmail, | ||
"name": conn.Name, | ||
"description": conn.Description, | ||
"status": conn.Status, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ func testAccMetalConnectionConfig_Shared(randstr string) string { | |
metro = "sv" | ||
speed = "50Mbps" | ||
service_token_type = "a_side" | ||
contact_email = "[email protected]" | ||
}`, | ||
randstr, randstr) | ||
} | ||
|
@@ -108,12 +109,12 @@ func TestAccMetalConnection_shared_zside(t *testing.T) { | |
"equinix_metal_connection.test", "service_tokens.0.type", "z_side"), | ||
resource.TestCheckResourceAttr( | ||
"equinix_metal_connection.test", "service_token_type", "z_side"), | ||
resource.TestCheckResourceAttrSet( | ||
"equinix_metal_connection.test", "contact_email"), | ||
), | ||
}, | ||
}, | ||
}) | ||
|
||
|
||
} | ||
|
||
func TestAccMetalConnection_shared(t *testing.T) { | ||
|
@@ -136,6 +137,8 @@ func TestAccMetalConnection_shared(t *testing.T) { | |
"equinix_metal_connection.test", "service_token_type", "a_side"), | ||
resource.TestCheckResourceAttr( | ||
"equinix_metal_connection.test", "service_tokens.0.max_allowed_speed", "50Mbps"), | ||
resource.TestCheckResourceAttr( | ||
"equinix_metal_connection.test", "contact_email", "[email protected]"), | ||
), | ||
}, | ||
{ | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nit: I'm not totally sold on labeling this
(Required)
, since it isn't always required; it looks like we went the opposite way withproject_id
, which is marked(Optional)
.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.
Fair enough. I'll merge and change that in a subsequent PR so as not to offend the pass status on tests.