Skip to content
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 Data Source: aws_workspaces_workspace #14135

Merged
merged 7 commits into from
Nov 5, 2020

Conversation

Tensho
Copy link
Contributor

@Tensho Tensho commented Jul 10, 2020

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_workspace`

Usage Example

Filter By Workspace ID

data "aws_workspaces_workspace" "test" {
  workspace_id = "ws-cj5xcxsz5"
}

Filter By Directory ID & User Name

data "aws_workspaces_workspace" "test" {
  directory_id = "d-9967252f57"
  user_name    = "alpha.test"
}

Notes

I haven't implemented a bundle_id filter intentionally, because it's already covered by the directory_id filter.

# May return multiple workspaces in different directories
data "aws_workspaces_workspace" "test" {
  bundle_id = "wsb-b0s22j3d7"
  user_name    = "alpha.test"
}

# bundle_id is redundant as user can have only 1 workspace in directory
data "aws_workspaces_workspace" "test" {
  directory_id = "d-9967252f57"
  bundle_id = "wsb-b0s22j3d7"
  user_name    = "alpha.test"
}

Acceptance Tests

$ make testacc TEST=./aws TESTARGS='-run=TestAccDataSourceAwsWorkspacesWorkspace' 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 1 -run=TestAccDataSourceAwsWorkspacesWorkspace -timeout 120m
=== RUN   TestAccDataSourceAwsWorkspacesWorkspace_byWorkspaceID
=== PAUSE TestAccDataSourceAwsWorkspacesWorkspace_byWorkspaceID
=== RUN   TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName
=== PAUSE TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName
=== RUN   TestAccDataSourceAwsWorkspacesWorkspace_workspaceIDAndDirectoryIDConflict
=== PAUSE TestAccDataSourceAwsWorkspacesWorkspace_workspaceIDAndDirectoryIDConflict
=== CONT  TestAccDataSourceAwsWorkspacesWorkspace_byWorkspaceID
--- PASS: TestAccDataSourceAwsWorkspacesWorkspace_byWorkspaceID (2083.29s)
=== CONT  TestAccDataSourceAwsWorkspacesWorkspace_workspaceIDAndDirectoryIDConflict
--- PASS: TestAccDataSourceAwsWorkspacesWorkspace_workspaceIDAndDirectoryIDConflict (2.99s)
=== CONT  TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName
--- PASS: TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName (2184.49s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	4274.536s

References

@Tensho Tensho requested a review from a team July 10, 2020 09:48
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. provider Pertains to the provider itself, rather than any interaction with AWS. documentation Introduces or discusses updates to documentation. service/workspaces Issues and PRs that pertain to the workspaces service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jul 10, 2020
@breathingdust breathingdust added new-data-source Introduces a new data source. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 10, 2020
@Tensho
Copy link
Contributor Author

Tensho commented Jul 14, 2020

@gdavison Hi ^_^ Please could you help me to understand this issue?

$ AWS_DEFAULT_REGION=us-east-1 make testacc TEST=./aws TESTARGS='-run=TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName'
...
 TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName: testing.go:684: Step 0 error: After applying this step and refreshing, the plan was not empty:

        DIFF:

        UPDATE: data.aws_workspaces_workspace.test
          bundle_id:                      "" => "<computed>"
          computer_name:                  "" => "<computed>"
          directory_id:                   "" => "d-90677c9a02"
          id:                             "" => "<computed>"
          ip_address:                     "" => "<computed>"
          root_volume_encryption_enabled: "" => "<computed>"
          state:                          "" => "<computed>"
          user_name:                      "" => "Administrator"
          user_volume_encryption_enabled: "" => "<computed>"
          volume_encryption_key:          "" => "<computed>"
          workspace_properties:           "" => "<computed>"
...

I can't grasp why does the plan for data source is not empty. What does it mean?

@teamterraform
Copy link

Notification of Recent and Upcoming Changes to Contributions

Thank you for this contribution! There have been a few recent development changes that affect this pull request. We apologize for the inconvenience, especially if there have been long review delays up until now. Please note that this is automated message from an unmonitored account. See the FAQ for additional information on the maintainer team and review prioritization.

If you are unable to complete these updates, please leave a comment for the community and maintainers so someone can potentially continue the work. The maintainers will encourage other contributors to use the existing contribution as the base for additional changes as appropriate. Otherwise, contributions that do not receive updated code or comments from the original contributor may be closed in the future so the maintainers can focus on active items.

For the most up to date information about Terraform AWS Provider development, see the Contributing Guide. Additional technical debt changes can be tracked with the technical-debt label on issues.

As part of updating a pull request with these changes, the most current unit testing and linting will run. These may report issues that were not previously reported.

Action Required: Terraform 0.12 Syntax

Reference: #8950
Reference: #14417

Version 3 and later of the Terraform AWS Provider, which all existing contributions would potentially be added, only supports Terraform 0.12 and later. Certain syntax elements of Terraform 0.11 and earlier show deprecation warnings during runs with Terraform 0.12. Documentation and test configurations, such as those including deprecated string interpolations (some_attribute = "${aws_service_thing.example.id}") should be updated to the newer syntax (some_attribute = aws_service_thing.example.id). Contribution testing will automatically fail on older syntax in the near future. Please see the referenced issues for additional information.

Action Required: Terraform Plugin SDK Version 2

Reference: #14551

The Terraform AWS Provider has been upgraded to the latest version of the Terraform Plugin SDK. Generally, most changes to contributions should only involve updating Go import paths in source code files. Please see the referenced issue for additional information.

Action Required: Removal of website/aws.erb File

Reference: #14712

Any changes to the website/aws.erb file are no longer necessary and should be removed from this contribution to prevent merge issues in the near future when the file is removed from the repository. Please see the referenced issue for additional information.

Upcoming Change of Git Branch Naming

Reference: #14292

Development environments will need their upstream Git branch updated from master to main in the near future. Please see the referenced issue for additional information and scheduling.

Upcoming Change of GitHub Organization

Reference: #14715

This repository will be migrating from https://github.com/terraform-providers/terraform-provider-aws to https://github.com/hashicorp/terraform-provider-aws. No practitioner or developer action is anticipated and most GitHub functionality will automatically redirect to the new location. Go import paths including terraform-providers can remain for now. Please see the referenced issue for additional information and scheduling.

@gdavison
Copy link
Contributor

I've never seen the error message "After applying this step and refreshing, the plan was not empty" for a data source. Is it possible that the error is about a resource, but it's buried in the output?

@Tensho
Copy link
Contributor Author

Tensho commented Sep 20, 2020

@gdavison Fixed tests. please check it out again 🙇

@ghost ghost added the service/fsx Issues and PRs that pertain to the fsx service. label Sep 21, 2020
@DrFaust92
Copy link
Collaborator

@Tensho, rebase to solve conflicts.

@ghost ghost added the service/sagemaker Issues and PRs that pertain to the sagemaker service. label Oct 14, 2020
@Tensho Tensho force-pushed the d-workspaces-workspace branch 2 times, most recently from 04a84bb to 1ffa4dc Compare October 15, 2020 10:17
@DrFaust92 DrFaust92 removed service/fsx Issues and PRs that pertain to the fsx service. service/sagemaker Issues and PRs that pertain to the sagemaker service. labels Oct 15, 2020
@DrFaust92
Copy link
Collaborator

DrFaust92 commented Oct 15, 2020

getting errors:


=== CONT  TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName
    data_source_aws_workspaces_workspace_test.go:49: Step 1/1 error: After applying this test step and performing a `terraform refresh`, the plan was not empty.
        stdout
        
        
        An execution plan has been generated and is shown below.
        Resource actions are indicated with the following symbols:
         <= read (data resources)
        
        Terraform will perform the following actions:
        
          # data.aws_workspaces_workspace.test will be read during apply
          # (config refers to values not yet known)
         <= data "aws_workspaces_workspace" "test"  {
              + bundle_id                      = (known after apply)
              + computer_name                  = (known after apply)
              + directory_id                   = "d-9267093919"
              + id                             = (known after apply)
              + ip_address                     = (known after apply)
              + root_volume_encryption_enabled = (known after apply)
              + state                          = (known after apply)
              + user_name                      = "Administrator"
              + user_volume_encryption_enabled = (known after apply)
              + volume_encryption_key          = (known after apply)
              + workspace_properties           = (known after apply)
            }
        
        Plan: 0 to add, 0 to change, 0 to destroy.



Error: workspace "ws-v6c832pkg" was not terminated: couldn't find resource (21 retries)


=== CONT  TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName
    testing_new.go:62: Error running post-test destroy, there may be dangling resources: 2020/10/15 15:21:22 [DEBUG] Using modified User-Agent: Terraform/0.12.29 HashiCorp-terraform-exec/0.10.0
        
        Error: workspace "ws-v6c832pkg" was not terminated: couldn't find resource (21 retries)
        
        
--- FAIL: TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName (1687.85s)

other are passing:

--- PASS: TestAccDataSourceAwsWorkspacesWorkspace_byWorkspaceID (1676.66s)
--- PASS: TestAccDataSourceAwsWorkspacesWorkspace_workspaceIDAndDirectoryIDConflict (5.82s)

@Tensho Tensho requested a review from a team as a code owner November 4, 2020 09:36
@Tensho
Copy link
Contributor Author

Tensho commented Nov 4, 2020

@ewbankkit Thanks for review 👍 I've fixed all the mentioned comments.

Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM.
(Unable to validate acceptance tests).

@breathingdust
Copy link
Member

LGTM 🚀 Thanks @Tensho for the contribution!

Verified Acceptance Tests in Commercial (us-west-2)

make testacc TEST=./aws TESTARGS='-run=TestAccDataSourceAwsWorkspacesWorkspace'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccDataSourceAwsWorkspacesWorkspace -timeout 120m
=== RUN   TestAccDataSourceAwsWorkspacesWorkspace_byWorkspaceID
=== PAUSE TestAccDataSourceAwsWorkspacesWorkspace_byWorkspaceID
=== RUN   TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName
=== PAUSE TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName
=== RUN   TestAccDataSourceAwsWorkspacesWorkspace_workspaceIDAndDirectoryIDConflict
=== PAUSE TestAccDataSourceAwsWorkspacesWorkspace_workspaceIDAndDirectoryIDConflict
=== CONT  TestAccDataSourceAwsWorkspacesWorkspace_byWorkspaceID
=== CONT  TestAccDataSourceAwsWorkspacesWorkspace_workspaceIDAndDirectoryIDConflict
=== CONT  TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName
--- PASS: TestAccDataSourceAwsWorkspacesWorkspace_workspaceIDAndDirectoryIDConflict (2.78s)
--- PASS: TestAccDataSourceAwsWorkspacesWorkspace_byDirectoryID_userName (1742.16s)
--- PASS: TestAccDataSourceAwsWorkspacesWorkspace_byWorkspaceID (1815.05s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	1816.658s

@breathingdust breathingdust added this to the v3.14.0 milestone Nov 5, 2020
@breathingdust breathingdust merged commit bd358a9 into hashicorp:master Nov 5, 2020
breathingdust added a commit that referenced this pull request Nov 5, 2020
@ghost
Copy link

ghost commented Nov 6, 2020

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

@Tensho Tensho deleted the d-workspaces-workspace branch November 9, 2020 09:06
@ghost
Copy link

ghost commented Dec 6, 2020

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 Dec 6, 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. new-data-source Introduces a new data source. provider Pertains to the provider itself, rather than any interaction with AWS. service/workspaces Issues and PRs that pertain to the workspaces service. size/XL 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.

6 participants