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

resource/aws_transfer_user: add home_directory_type and home_directory_mappings arguments #13591

Merged
merged 2 commits into from
Sep 21, 2020
Merged

resource/aws_transfer_user: add home_directory_type and home_directory_mappings arguments #13591

merged 2 commits into from
Sep 21, 2020

Conversation

quinyx-tjeerd
Copy link

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

Original PR:
#11483

I resolved the conflict

Closes #11281
Relates #11632

Release note for CHANGELOG:

Add home_directory_type and home_directory_mappings arguments to aws_transfer_user resource

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSTransferUser_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -count 1 -parallel 20 -run=TestAccAWSTransferUser_ -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAWSTransferUser_basic
=== PAUSE TestAccAWSTransferUser_basic
=== RUN   TestAccAWSTransferUser_modifyWithOptions
=== PAUSE TestAccAWSTransferUser_modifyWithOptions
=== RUN   TestAccAWSTransferUser_disappears
=== PAUSE TestAccAWSTransferUser_disappears
=== RUN   TestAccAWSTransferUser_UserName_Validation
=== PAUSE TestAccAWSTransferUser_UserName_Validation
=== RUN   TestAccAWSTransferUser_homeDirectoryMappings
=== PAUSE TestAccAWSTransferUser_homeDirectoryMappings
=== CONT  TestAccAWSTransferUser_basic
=== CONT  TestAccAWSTransferUser_UserName_Validation
=== CONT  TestAccAWSTransferUser_disappears
=== CONT  TestAccAWSTransferUser_homeDirectoryMappings
=== CONT  TestAccAWSTransferUser_modifyWithOptions
--- PASS: TestAccAWSTransferUser_UserName_Validation (15.55s)
--- PASS: TestAccAWSTransferUser_disappears (45.52s)
--- PASS: TestAccAWSTransferUser_basic (49.50s)
--- PASS: TestAccAWSTransferUser_homeDirectoryMappings (73.62s)
--- PASS: TestAccAWSTransferUser_modifyWithOptions (112.28s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	113.609s
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/flatmap	0.421s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags	0.671s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/naming	0.890s [no tests to run]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/apigatewayv2/waiter	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/batch/equivalency	0.829s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/eks/token	0.236s [no tests to run]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/guardduty/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/iam/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/kinesisanalytics/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/kms/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/neptune/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/rds/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/secretsmanager/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/servicediscovery/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/workspaces/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/awsproviderlint	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/helper/awsprovidertype/keyvaluetags	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/passes	1.587s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/passes/AWSAT001	2.180s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/passes/AWSR001	0.613s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/passes/AWSR002	1.231s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/passes/fmtsprintfcallexpr	0.462s [no tests to run]
...

@quinyx-tjeerd quinyx-tjeerd requested a review from a team June 3, 2020 12:08
@ghost ghost added size/L Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. service/transfer Issues and PRs that pertain to the transfer service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jun 3, 2020
@sallaben
Copy link
Contributor

sallaben commented Jun 4, 2020

Thanks for the PR! Does this functionality differ from the functionality in #12599?

@quinyx-tjeerd
Copy link
Author

This functionality is a subset of the pr you mention, which could (and possibly should) have been separated so it could add value sooner. I could revise the code so it matches the mentioned pr?

@rprieto
Copy link

rprieto commented Aug 7, 2020

Is it possible to merge this PR? It's indeed covered by 12599 - however that one implements several features and seems to be blocked on an unrelated topic, waiting for another PR itself (VPC endpoint). Without this functionality we must fall back to CloudFormation to manage AWS Transfer users, especially as directory mappings are not available in the AWS Console. Thanks.

@dturnbu
Copy link

dturnbu commented Aug 17, 2020

Who is this "AWS Provider" guy and why hasn't he reviewed this PR? I've been waiting for this for weeks now and it looks like others have been waiting even longer.

How is it this simple, yet valuable fix hasn't made it into one of the several releases since this PRs creation?

@quinyx-tjeerd
Copy link
Author

In case it helps you out, I worked around this issue by:
adding AWS cli to the image where terraform runs, and using local-exec.
this might or might not be an option for you, depending on where your terraform runs.

resource "aws_transfer_user" "sftp-users" {
  server_id = aws_transfer_server.server.id
  role      = aws_iam_role.sftp-user.arn
  user_name = "username"

  # This bit can be replaced once 'home-directory-type' and 'home-directory-mappings' are available in terraform aws provider
  provisioner "local-exec" {
    command = "aws transfer update-user --server-id $SERVER --user-name $USER --region $REGION --home-directory-type $HOME_DIR_TYPE --home-directory-mappings $HOME_DIR_MAPPINGS"

    environment = {
      SERVER            = aws_transfer_server.server.id
      USER              = "username"
      REGION            = var.region
      HOME_DIR_TYPE     = "LOGICAL"
      HOME_DIR_MAPPINGS = format("Entry=/,Target=/%s/%s", aws_s3_bucket.sftp-bucket.id, "username")
    }
  }
}

@dturnbu
Copy link

dturnbu commented Aug 17, 2020

In case it helps you out, I worked around this issue by:
adding AWS cli to the image where terraform runs, and using local-exec.
this might or might not be an option for you, depending on where your terraform runs.

resource "aws_transfer_user" "sftp-users" {
  server_id = aws_transfer_server.server.id
  role      = aws_iam_role.sftp-user.arn
  user_name = "username"

  # This bit can be replaced once 'home-directory-type' and 'home-directory-mappings' are available in terraform aws provider
  provisioner "local-exec" {
    command = "aws transfer update-user --server-id $SERVER --user-name $USER --region $REGION --home-directory-type $HOME_DIR_TYPE --home-directory-mappings $HOME_DIR_MAPPINGS"

    environment = {
      SERVER            = aws_transfer_server.server.id
      USER              = "username"
      REGION            = var.region
      HOME_DIR_TYPE     = "LOGICAL"
      HOME_DIR_MAPPINGS = format("Entry=/,Target=/%s/%s", aws_s3_bucket.sftp-bucket.id, "username")
    }
  }
}

Thank you very much, I'll give it a shot! I'm trying to run this from Terraform Cloud, hopefully their executors allow local-exec operations.....

@quinyx-tjeerd
Copy link
Author

quinyx-tjeerd commented Aug 18, 2020

Thank you very much, I'll give it a shot! I'm trying to run this from Terraform Cloud, hopefully their executors allow local-exec operations.....

I used Terraform Cloud before at a previous company, and local-exec was not the problem but i'd image you don't have AWS cli available in the images they run on 😅
and back then I haven't looked into the functionality / flexibility of providing your own images.

@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 21, 2020
@bflad bflad self-assigned this Sep 21, 2020
@bflad bflad added this to the v3.8.0 milestone Sep 21, 2020
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

This looks good, thanks for the updates here, @quinyx-tjeerd 🚀

Output from acceptance testing:

--- PASS: TestAccAWSTransferUser_basic (20.00s)
--- PASS: TestAccAWSTransferUser_disappears (16.77s)
--- PASS: TestAccAWSTransferUser_homeDirectoryMappings (30.78s)
--- PASS: TestAccAWSTransferUser_modifyWithOptions (43.38s)
--- PASS: TestAccAWSTransferUser_UserName_Validation (8.93s)


resource "aws_iam_role_policy" "foo" {
name = "tf-test-transfer-user-iam-policy-%s"
role = "${aws_iam_role.foo.id}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: We are now using Terraform 0.12+ syntax in test configurations, will adjust on merge. 👍

@bflad bflad merged commit 329e343 into hashicorp:master Sep 21, 2020
bflad added a commit that referenced this pull request Sep 21, 2020
@ghost
Copy link

ghost commented Sep 24, 2020

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
Copy link

ghost commented Oct 21, 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 Oct 21, 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. enhancement Requests to existing resources that expand the functionality or scope. service/transfer Issues and PRs that pertain to the transfer 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.

aws_transfer_user should provide home-directory-mappings option.
6 participants