-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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_public_virtual_interface #3252
Conversation
Acceptance tests require an active Direct Connect connection which should be specified via the
|
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.
Thanks for this PR @ewbankkit
It's looking good overall, just a few questions pending.
aws/dx_vif.go
Outdated
"tags": tagsSchema(), | ||
}, | ||
) | ||
var dxVirtualInterfaceSchema = map[string]*schema.Schema{ |
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.
Do you mind moving all the schema related code to the top of the file? It's just a convention we tend to follow.
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.
Will do.
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.
Done.
aws/dx_vif.go
Outdated
return isAWSErr(err, "DirectConnectClientException", "does not exist") | ||
} | ||
|
||
func dxVirtualInterfaceRead(d *schema.ResourceData, meta interface{}) (*directconnect.VirtualInterface, error) { |
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.
Do you mind reducing the interface to bare minimum here? e.g. (id string, conn *directconnect.DirectConnect)
?
Exceptions apply, but ideally only CRUD should be responsible for modifying the state, i.e. calling d.SetId("")
.
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.
Will do.
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.
Done. I also changed the checking to just remove the resource from state when the status is Deleted
and not Deleting
or Rejected
, similar to #2990.
connectionId := os.Getenv(key) | ||
if connectionId == "" { | ||
t.Skipf("Environment variable %s is not set", key) | ||
} |
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.
Can't we just automatically create the DX connection as part of the test here?
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.
The problem is that the connection needs to be in the Active
state for any of the Virtual Interface functionality to succeed and activation of a connection requires sending a Letter of Activation to the network/CoLo provider and manual work on their side; i.e. plenty of time and money.
I have been testing on connections that already have active but aren't used for live traffic.
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.
Hi @ewbankkit, we are just about to implement two new Direct Connect connections in eu-west-2, and in advance I created a test connection in a sandbox account so that I could map out the Virtual interfaces I needed. I have no intention of ever sending the LOA for this connection, but I am able to create and attach Virtual Interfaces to it, even though it is in the down state.
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.
@X-Guardian What state does the Virtual Interface end up in? The resource won't be successfully created unless it ends up in available or verifying states.
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.
@ewbankkit, I can create a Virtual Interface resource connected to either a DC Gateway or a VPG, and it creates successfully. Yes, it has a status of down of course, but does that matter?
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.
@X-Guardian When I try and create a Direct Connect Connection and then a Public Virtual Interface on that connection in the acceptance test
resource "aws_dx_connection" "foo" {
name = "%s"
bandwidth = "1Gbps"
location = "EqSe2"
}
resource "aws_dx_public_virtual_interface" "foo" {
connection_id = "${aws_dx_connection.foo.id}"
name = "%s"
vlan = 4094
address_family = "ipv4"
bgp_asn = 65352
customer_address = "175.45.176.1/30"
amazon_address = "175.45.176.2/30"
route_filter_prefixes = [
"210.52.109.0/24",
"175.45.176.0/22"
]
}
then the test fails
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsDxPublicVirtualInterface_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -run=TestAccAwsDxPublicVirtualInterface_ -timeout 120m
=== RUN TestAccAwsDxPublicVirtualInterface_basic
--- FAIL: TestAccAwsDxPublicVirtualInterface_basic (20.73s)
testing.go:518: Step 0 error: Error applying: 1 error(s) occurred:
* aws_dx_public_virtual_interface.foo: 1 error(s) occurred:
* aws_dx_public_virtual_interface.foo: Error creating Direct Connect public virtual interface: DirectConnectClientException: The specified Connection ID is not available
status code: 400, request id: 0fb430bb-6c2f-11e8-8b43-895a753e5994
FAIL
exit status 1
FAIL github.com/terraform-providers/terraform-provider-aws/aws 20.744s
The connection is in the requested state when the VIF is created on it.
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.
@ewbankkit, when I have created a Direct Connect connection, it can take anything from 15 minutes to several hours to move on from the 'ordering' state, depending upon the partner chosen. Can you split your dx connection test from your virtual interface test?
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.
@X-Guardian Yes, that's why the acceptance tests require the environment variable DX_CONNECTION_ID
to be set to the ID of the connection created elsewhere.
"175.45.176.0/22" | ||
] | ||
} | ||
`, cid, n) |
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.
Nitpick: indentation.
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.
Fixed.
Environment = "test" | ||
} | ||
} | ||
`, cid, n) |
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.
Nitpick: indentation.
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.
Fixed.
Have we been able to address the conflicts here @bflad? @ewbankkit did you already look into that and I missed it? Beth |
Rebased and re-ran acceptance tests: $ export DX_CONNECTION_ID=dxcon-xxxxxxxx
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsDxPublicVirtualInterface_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -run=TestAccAwsDxPublicVirtualInterface_ -timeout 120m
=== RUN TestAccAwsDxPublicVirtualInterface_basic
--- PASS: TestAccAwsDxPublicVirtualInterface_basic (44.90s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 45.528s |
Rebased to remove conflict. |
Confirming acceptance tests in $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsDxPublicVirtualInterface_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -run=TestAccAwsDxPublicVirtualInterface_ -timeout 120m
=== RUN TestAccAwsDxPublicVirtualInterface_basic
--- PASS: TestAccAwsDxPublicVirtualInterface_basic (46.56s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 46.571s |
Changes after code review on #3253. $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsDxPublicVirtualInterface_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -run=TestAccAwsDxPublicVirtualInterface_ -timeout 120m
=== RUN TestAccAwsDxPublicVirtualInterface_basic
--- PASS: TestAccAwsDxPublicVirtualInterface_basic (63.21s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 77.962s |
Acceptance tests in $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsDxPublicVirtualInterface_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -run=TestAccAwsDxPublicVirtualInterface_ -timeout 120m
=== RUN TestAccAwsDxPublicVirtualInterface_basic
--- PASS: TestAccAwsDxPublicVirtualInterface_basic (69.70s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 69.723s |
Here is a small test case provider "aws" {
max_retries = 3
region = "eu-central-1"
profile = "connect"
}
variable "connection_id" {
default = "dxcon-zzzzzzzz"
}
resource "aws_dx_public_virtual_interface" "test" {
connection_id = "${var.connection_id}"
name = "vif-test"
vlan = 1
address_family = "ipv4"
bgp_asn = 65001
customer_address = "175.45.176.1/30"
amazon_address = "175.45.176.2/30"
route_filter_prefixes = [
"210.52.109.0/24",
"175.45.176.0/22",
]
} $ terraform apply
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
+ aws_dx_public_virtual_interface.test
id: <computed>
address_family: "ipv4"
amazon_address: "175.45.176.2/30"
arn: <computed>
bgp_asn: "65001"
bgp_auth_key: <computed>
connection_id: "dxcon-zzzzzzzz"
customer_address: "175.45.176.1/30"
name: "vif-test"
route_filter_prefixes.#: "2"
route_filter_prefixes.1752038751: "210.52.109.0/24"
route_filter_prefixes.4290081960: "175.45.176.0/22"
vlan: "1"
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_dx_public_virtual_interface.test: Creating...
address_family: "" => "ipv4"
amazon_address: "" => "175.45.176.2/30"
arn: "" => "<computed>"
bgp_asn: "" => "65001"
bgp_auth_key: "" => "<computed>"
connection_id: "" => "dxcon-zzzzzzzz"
customer_address: "" => "175.45.176.1/30"
name: "" => "vif-test"
route_filter_prefixes.#: "" => "2"
route_filter_prefixes.1752038751: "" => "210.52.109.0/24"
route_filter_prefixes.4290081960: "" => "175.45.176.0/22"
vlan: "" => "1"
aws_dx_public_virtual_interface.test: Still creating... (10s elapsed)
aws_dx_public_virtual_interface.test: Creation complete after 11s (ID: dxvif-fhccct40)
Apply complete! Resources: 1 added, 0 changed, 0 destroyed. $ terraform apply
aws_dx_public_virtual_interface.test: Refreshing state... (ID: dxvif-fhccct40)
Apply complete! Resources: 0 added, 0 changed, 0 destroyed. $ terraform destroy
aws_dx_public_virtual_interface.test: Refreshing state... (ID: dxvif-fhccct40)
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
- destroy
Terraform will perform the following actions:
- aws_dx_public_virtual_interface.test
Plan: 0 to add, 0 to change, 1 to destroy.
Do you really want to destroy?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
aws_dx_public_virtual_interface.test: Destroying... (ID: dxvif-fhccct40)
aws_dx_public_virtual_interface.test: Still destroying... (ID: dxvif-fhccct40, 10s elapsed)
aws_dx_public_virtual_interface.test: Destruction complete after 11s
Destroy complete! Resources: 1 destroyed. |
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.
Looks great, thanks @ewbankkit! I'll fix the merge conflicts from merging the other Direct Connect PRs 🚀
This has been released in version 1.25.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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! |
Fixes #3248.
aws/dx_vif.go
and changes toaws/utils*.go
shared with:aws/tagsDX*.go
copied from: