-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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_workspaces_directory #11023
Conversation
7782d38
to
351401b
Compare
Thanks for this submission, @Tensho, it's a great start. There are a few things to look at before we merge it in. The Update function is empty, and I assume that this is because the The Workspaces Directory needs the IAM role In your tests, you've specified availability zones by name. Please either add a provisioner block with the region or make the availability zones region-independent, for example by using the Please add a reference to the resource documentation in the file https://github.com/terraform-providers/terraform-provider-aws/blob/master/website/aws.erb |
@gdavison Hi Graham, thank you for the quick assistance 🙇 Nor AWS Web Console neither AWS CLI/API don't allow to change The reason I specified exact AZs in tests – Workspaces service was not available in all regions and AZs. Once I ran into the issue registering directory in
or
Anyway, I tried
I understand it's reasonable to diverse test coverage across the different regions and AZs, but how do you setup acc test for resources that are unsupported in a particular region yet? As for |
Our tests default to running in To make things a little more complicated, AZ names are not consistent across accounts (https://docs.aws.amazon.com/ram/latest/userguide/working-with-az-ids.html), so using the AZ names isn't enough. However, I did manage to figure out how to make it work in either data "aws_region" "current" {}
data "aws_availability_zones" "available" {
state = "available"
}
locals {
region_allowed_az_ids = {
"us-east-1" = formatlist("use1-az%d", [2, 4, 6])
}
allowed_az_ids = lookup(local.region_allowed_az_ids, data.aws_region.current.name, data.aws_availability_zones.available.zone_ids)
}
resource "aws_subnet" "test-a" {
vpc_id = "${aws_vpc.test.id}"
availability_zone_id = local.allowed_az_ids[0]
cidr_block = "10.0.1.0/24"
}
resource "aws_subnet" "test-c" {
vpc_id = "${aws_vpc.test.id}"
availability_zone_id = local.allowed_az_ids[1]
cidr_block = "10.0.2.0/24"
} |
For the case of changing subnets assigned to the directory, I was thinking more of an error case where the user creating the Terraform configuration didn't assign all subnets and needs to correct their code. For example (I've excluded unimportant attributes): First pass: resource "aws_subnet" "test-a" {}
resource "aws_subnet" "test-c" {}
resource "aws_directory_service_directory" "test" {
vpc_settings {
subnet_ids = ["${aws_subnet.test-a.id}","${aws_subnet.test-c.id}"]
}
}
resource "aws_workspaces_directory" "test" {
directory_id = "${aws_directory_service_directory.test.id}"
subnet_ids = ["${aws_subnet.test-a.id}"]
} Second pass, they add the second subnet: resource "aws_workspaces_directory" "test" {
directory_id = "${aws_directory_service_directory.test.id}"
subnet_ids = ["${aws_subnet.test-a.id}", "${aws_subnet.test-c.id}"]
} This won't update the |
c2fa3f9
to
dcf4909
Compare
@gdavison Added Regarding subnets I agree, despite there is no update API for them, I guess it's reasonable to add a validation function to make sure specified subnets are correct. I'll check subnets behavior with AWS Support to get a better understanding of their implications. |
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's looking good. Just a couple changes and we can get this merged in. Thanks!
30c138f
to
204791f
Compare
Since both attributes are |
…workspaces security groups
35f6216
to
11a79bf
Compare
Legacy SDK doesn't add new tags, but overwrites existing ones. Here is a warning in debug mode: [WARN] Provider "aws" produced an unexpected new value for aws_workspaces_directory.main, but we are tolerating it because it is using the legacy plugin SDK. The following problems may be the cause of any confusing errors from downstream operations: - .tags: element "Directory" has vanished
I've tested workspaces tags update within AWS CLI and it works as expected:
Seems like the problem in legacy AWS Go SDK according to the warning I see:
I've added custom |
@gdavison Please let me know if I can do anything else here 🙇 It would be nice to squash all review commits on merge. |
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 🚀 The acceptance tests pass on my workstation, but have a race condition around the IAM role workspaces_DefaultRole
in CI. The tests will need to be serialized in a subsequent PR.
--- PASS: TestAccAwsWorkspacesDirectory_basic (631.95s)
--- PASS: TestAccAwsWorkspacesDirectory_subnetIds (608.25s)
--- PASS: TestAccAwsWorkspacesIpGroup_basic (32.88s)
This has been released in version 2.44.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 for triage. Thanks! |
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! |
Community Note
Example
Test
Output from acceptance testing:
Notes
Workspaces API still lacks a lot of features support and is not consistent. However, this resource opens the doors to other Workspaces resource, check out #434. I've already requested a couple of AWS API features to support other attributes support and will add them to the resource as soon as it will be possible.
References
References