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

[Bug]: Unable to use import block for datasync_location_nfs #33381

Closed
psjd23 opened this issue Sep 8, 2023 · 3 comments · Fixed by #36072
Closed

[Bug]: Unable to use import block for datasync_location_nfs #33381

psjd23 opened this issue Sep 8, 2023 · 3 comments · Fixed by #36072
Labels
bug Addresses a defect in current functionality. service/datasync Issues and PRs that pertain to the datasync service.
Milestone

Comments

@psjd23
Copy link

psjd23 commented Sep 8, 2023

Terraform Core Version

1.5.2,1.5.7

AWS Provider Version

5.15.0,5.16.0

Affected Resource(s)

  • datasync_location_nfs
  • datasync_location_efs

Expected Behavior

NFS location should be imported successfully and added to state without an errors. Server_hostname should be populated from existing task location in AWS.

Actual Behavior

  • Error regarding missing argument "server_hostname".
  • Attempts to input the IP or hostname forces a replacement of the resource (bad, because tasks are dependent on the location, meaning everything must be replaced).
  • Does not get added to state

Relevant Error/Panic Output Snippet

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Missing required argument
│ 
│   with aws_datasync_location_nfs.onprem_nfs,
│   on generated.tf line 1:
│   (source code not available)
│ 
│ The argument "server_hostname" is required, but no definition was found.

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "5.16.0"
    }
  }
}

provider "aws" {
  region = "us-east-1"
}

terraform {
  backend "local" {
    path = "terraform.tfstate"
  }
}

import {
  to = aws_datasync_location_nfs.onprem_nfs
  id = "arn:aws:datasync:us-east-1:XXXXXXXXXXXX:location/loc-XXXXXXXXXXXXXXXXX"
}

Steps to Reproduce

  • Create an import block to import an existing DataSync NFS task location
  • Run terraform plan -generate-config-out=generated.tf

Debug Output

N/A

Panic Output

N/A

Important Factoids

I am able to import the resource successfully using "state surgery" by following this workflow:

  • Migrate remote state to local
  • Import the resource using CLI
terraform import aws_datasync_location_nfs.onprem_nfs arn:aws:datasync:us-east-1:XXXXXXXXXXXX:location/loc-XXXXXXXXXXXXXXXXX
  • Modify server_hostname in terraform.state from null to NFS IP (i.e., 192.168.0.22)
  • Run terraform plan and see "No changes. Your infrastructure matches the configuration."

References

It appears the import command doesn't know how to read the hostname or IP after nfs://. Below is the response from AWS CLI, you will see that server_hostname is not a valid output. Should a fix involve capturing the hostname from LocationUri?

aws datasync describe-location-nfs --location-arn "arn:aws:datasync:us-east-1:XXXXXXXXXXXX:location/loc-XXXXXXXXXXXX"
{
    "LocationArn": "arn:aws:datasync:us-east-1:XXXXXXXXXXXX:location/loc-XXXXXXXXXXXX",
    "LocationUri": "nfs://192.168.0.22/onprem_nfs/",
    "OnPremConfig": {
        "AgentArns": [
            "arn:aws:datasync:us-east-1:XXXXXXXXXXXX:agent/agent-XXXXXXXXXXXX"
        ]
    },
    "MountOptions": {
        "Version": "AUTOMATIC"
    },
    "CreationTime": "2023-08-30T10:05:03.268000-04:00"
}

Would you like to implement a fix?

None

EDIT
The same issue occurs when importing datasync_location_efs. "efs_file_system_arn": null exists in the state file for an imported DataSync EFS location. This issue probably spreads to other datasync sources as well but I am unable to test all.

@psjd23 psjd23 added the bug Addresses a defect in current functionality. label Sep 8, 2023
@github-actions
Copy link

github-actions bot commented Sep 8, 2023

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 8, 2023
@justinretzolk justinretzolk added service/datasync Issues and PRs that pertain to the datasync service. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 11, 2023
@github-actions github-actions bot added this to the v5.42.0 milestone Mar 19, 2024
Copy link

This functionality has been released in v5.42.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. Thank you!

Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/datasync Issues and PRs that pertain to the datasync service.
Projects
None yet
2 participants