Skip to content

New Data Source: aws_workspaces_image#11428

Merged
gdavison merged 3 commits into
hashicorp:masterfrom
Tensho:d-workspaces-image
Sep 24, 2020
Merged

New Data Source: aws_workspaces_image#11428
gdavison merged 3 commits into
hashicorp:masterfrom
Tensho:d-workspaces-image

Conversation

@Tensho

@Tensho Tensho commented Dec 27, 2019

Copy link
Copy Markdown
Contributor

Community Note

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

Release note for CHANGELOG:

New Data Source: aws_workspaces_image (#11428)

Example

data "aws_workspaces_image" "example" {
  image_id = "wsi-ten5h0y19"
}

TODO

  • Create aws_workspaces_image resource before inspecting it with the described data source

Acceptance Tests

$ AWS_WORKSPACES_IMAGE_ID=wsi-vwtykwqyx AWS_DEFAULT_REGION=us-east-1 make testacc TEST=./aws TESTARGS='-run=TestAccDataSourceAwsWorkspacesImage_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccDataSourceAwsWorkspacesImage_basic -timeout 120m
=== RUN   TestAccDataSourceAwsWorkspacesImage_basic
=== PAUSE TestAccDataSourceAwsWorkspacesImage_basic
=== CONT  TestAccDataSourceAwsWorkspacesImage_basic
--- PASS: TestAccDataSourceAwsWorkspacesImage_basic (30.84s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	34.844s

References

@Tensho Tensho requested a review from a team December 27, 2019 12:35
@ghost ghost added needs-triage Waiting for first response or review from a maintainer. size/M Managed by automation to categorize the size of a PR. provider Pertains to the provider itself, rather than any interaction with AWS. service/workspaces Issues and PRs that pertain to the workspaces service. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Dec 27, 2019
@Tensho

Tensho commented Dec 27, 2019

Copy link
Copy Markdown
Contributor Author

Unfortunately, it's not possible to create an image with the API at the moment, I've requested corresponding API action with AWS Support ticket.
The current test passes for the manually created image in AWS Web Management Console.

@Tensho Tensho force-pushed the d-workspaces-image branch from 276e7a4 to d4d041d Compare January 11, 2020 12:31
Comment thread aws/data_source_aws_workspaces_image.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will probably want to check len(resp.Images) > 0 here.
See #11837.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, will add

@Tensho Tensho force-pushed the d-workspaces-image branch 3 times, most recently from 51ca002 to dc2f918 Compare May 28, 2020 08:25
@gdavison gdavison self-assigned this Jun 3, 2020
@gdavison gdavison removed the needs-triage Waiting for first response or review from a maintainer. label Jun 4, 2020

@gdavison gdavison left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, @Tensho. A couple changes to make.

Comment thread aws/data_source_aws_workspaces_image.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This won't pass in our testing environments, since the image is owned by your account.

We could add an environment variable for the image ID and have a pre-check function that checks for the environment variable. Alternatively, there are API functions to import AMIs as Workspace images.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I like the idea with environment variable, will add the pre-check for now. Unfortunately, ImportWorkspaceImage API works only with Windows. I've submitted respective feature request to AWS Support last year. Is it OK to create aws_workspace_image Terraform resource only for Windows, while AWS supports Linux images too?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, we can do that. We'll just need to document that it only supports Windows images because of the AWS API

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, even Windows images could be imported only with BYOL, which looks like a totally separate feature.

@Tensho Tensho force-pushed the d-workspaces-image branch from dc2f918 to 6ed0c56 Compare June 5, 2020 08:47
@ghost ghost added size/L Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Jun 5, 2020
@Tensho

Tensho commented Jun 5, 2020

Copy link
Copy Markdown
Contributor Author

@gdavison Thank you, I've added fixes according to your review, please let me know if I can do anything else here 🙇

@gdavison gdavison left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test will need to be updated to handle arbitrary image ids

Comment on lines 24 to 29

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we're retrieving a WorkSpaces Image using an arbitrary ID, we won't know these values beforehand. You might be able to test this by retrieving the API resource by ID, and then comparing the values in the Terraform resource state. testAccCheckEfsMountTarget() is an example of the approach you could take

@Tensho Tensho Jun 19, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

testAccCheckEfsMountTarget() retrieves actual resource attributes within AWS API, but doesn't test them against state 😄 But I got the idea, you meant item 2 at Anatomy of an Acceptance TesttestAccCheckCloudWatchDashboardExists().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the environment variable isn't set, this should skip the test instead of failing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@gdavison gdavison added the waiting-response Maintainers are waiting on response from community or contributor. label Jun 18, 2020
@Tensho Tensho force-pushed the d-workspaces-image branch 2 times, most recently from 4bf7c79 to bc6e5a5 Compare June 21, 2020 21:57
@Tensho

Tensho commented Jun 21, 2020

Copy link
Copy Markdown
Contributor Author

@gdavison FIxed, check it out again.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Jun 21, 2020
@Tensho Tensho force-pushed the d-workspaces-image branch from bc6e5a5 to 5fc6e61 Compare June 21, 2020 21:59

@gdavison gdavison left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking good. It will need to be rebased, and I have a few suggested changes.

Comment thread aws/data_source_aws_workspaces_image_test.go Outdated
Comment thread aws/data_source_aws_workspaces_image_test.go Outdated
Comment thread aws/data_source_aws_workspaces_image.go Outdated
Comment thread aws/data_source_aws_workspaces_image.go Outdated
Comment on lines 36 to 39

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can remove the state attribute, since it is more of a run-time property, not a configuration property.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But this is a data source, not a resource. Don't we need to get info about any possible attribute there?

Comment thread aws/data_source_aws_workspaces_image.go Outdated
@Tensho Tensho force-pushed the d-workspaces-image branch from 5fc6e61 to b775925 Compare July 15, 2020 08:05
@Tensho

Tensho commented Jul 15, 2020

Copy link
Copy Markdown
Contributor Author

@gdavison Adjusted according to your comments. Please let me know if you need anything else 🙇

I also work on aws_workspaces_workspace data source, but I've stuck with one test. If you have some time to look there, please could you guide me the right direction 🙇

@Tensho Tensho force-pushed the d-workspaces-image branch from b775925 to b4ba8f2 Compare August 25, 2020 10:02
@Tensho Tensho force-pushed the d-workspaces-image branch from d0e321f to e4e2c52 Compare August 25, 2020 12:50
@Tensho

Tensho commented Aug 25, 2020

Copy link
Copy Markdown
Contributor Author

@gdavison @ewbankkit Hi ^_^ Please could you check it again?

@gdavison gdavison left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 🚀

--- PASS: TestAccDataSourceAwsWorkspacesImage_basic (54.32s)

@gdavison gdavison added this to the v3.8.0 milestone Sep 17, 2020
@Tensho

Tensho commented Sep 18, 2020

Copy link
Copy Markdown
Contributor Author

@gdavison Thank you 🙇

@gdavison gdavison merged commit c7d40f2 into hashicorp:master Sep 24, 2020
gdavison added a commit that referenced this pull request Sep 24, 2020
@ghost

ghost commented Sep 24, 2020

Copy link
Copy Markdown

This has been released in version 3.8.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!

@ghost

ghost commented Oct 25, 2020

Copy link
Copy Markdown

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!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 25, 2020
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. provider Pertains to the provider itself, rather than any interaction with AWS. service/workspaces Issues and PRs that pertain to the workspaces service. size/L 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.

3 participants