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

aws_fsx_windows_file_system Resource Crashes on Change #11500

Closed
tlanghals-uturn opened this issue Jan 6, 2020 · 5 comments · Fixed by #12630
Closed

aws_fsx_windows_file_system Resource Crashes on Change #11500

tlanghals-uturn opened this issue Jan 6, 2020 · 5 comments · Fixed by #12630
Assignees
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/fsx Issues and PRs that pertain to the fsx service.
Milestone

Comments

@tlanghals-uturn
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue 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 issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.18

  • provider.aws v2.43.0
  • provider.null v2.1.2

Affected Resource(s)

  • aws_fsx_windows_file_system

Terraform Configuration Files

resource "aws_fsx_windows_file_system" "main" {
  kms_key_id          = var.kms_key_id
  storage_capacity    = var.storage
  subnet_ids          = var.subnet_ids
  security_group_ids  = var.security_group_ids
  throughput_capacity = var.throughput

  self_managed_active_directory {
    dns_ips                                = ["172.16.0.53", "172.16.1.53"]
    domain_name                            = "example.com"
    organizational_unit_distinguished_name = "OU=FSX,OU=Servers,DC=Example,DC=com"
    username                               = "aws_fsx"
    password                               = data.aws_ssm_parameter.aws_fsx.value
    file_system_administrators_group       = "AWS FSX Admins"
  }

  copy_tags_to_backups              = false
  daily_automatic_backup_start_time = "02:00"
  automatic_backup_retention_days   = "14"
  weekly_maintenance_start_time     = "6:07:30"

  tags = merge(
    {
      "Name" = "STZHALFSX02",
      "Role" = "File Server",
    },
    var.tags,
  )

  lifecycle {
    ignore_changes = [
      storage_capacity,
      security_group_ids,
      self_managed_active_directory.0.password
    ]
  }
}

Debug Output

https://gist.github.com/tlanghals-uturn/30bacf2044b2abc2ec79230bff87c695

Panic Output

https://gist.github.com/tlanghals-uturn/c9b3310ab39ebc35b6200f9e8b4b834c/555b8f11abc4b6238072e6aa68437461eb4ab519

Expected Behavior

Name Tag or other changed values should be updated on the aws_windows_file_system resource.

Actual Behavior

Terraform errors out with "rpc error: code = Unavailable desc = transport is closing"

Steps to Reproduce

  1. Update a Tag value or Maintenance or Backup Time
  2. terraform apply

Important Factoids

Resource state was imported into Terraform

@ghost ghost added the service/fsx Issues and PRs that pertain to the fsx service. label Jan 6, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 6, 2020
@bflad bflad added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. and removed needs-triage Waiting for first response or review from a maintainer. labels Jan 6, 2020
@bflad
Copy link
Contributor

bflad commented Jan 6, 2020

Hi @tlanghals-uturn 👋 Thank you for reporting this and sorry you ran into trouble here. There is a resource code issue, but I'm not sure if there is an easy workaround short of manually updating any non-tags changes outside of Terraform in your situation until this is fixed.

The relevant portion of crash log:

2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: panic: interface conversion: interface {} is *schema.Set, not []interface {}
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: 
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: goroutine 121 [running]:
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: github.com/terraform-providers/terraform-provider-aws/aws.expandFsxSelfManagedActiveDirectoryConfigurationUpdate(0xc000820e60, 0x1, 0x1, 0x426e7a0)
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_fsx_windows_file_system.go:410 +0x2e1
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsFsxWindowsFileSystemUpdate(0xc0000cab60, 0x4211c80, 0xc00029a000, 0x0, 0x0)
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_fsx_windows_file_system.go:266 +0x5e9
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc000557200, 0xc000c8bd10, 0xc000edca60, 0x4211c80, 0xc00029a000, 0xc000eaed01, 0xc000a141e0, 0x40f3e8)
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.4.1/helper/schema/resource.go:311 +0x26a
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc00072f000, 0xc000d57918, 0xc000c8bd10, 0xc000edca60, 0xc000ebd288, 0xc000131220, 0x47e9cc0)
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.4.1/helper/schema/provider.go:294 +0xa0
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc0000076f0, 0x5c67940, 0xc0009fca50, 0xc000b5fc20, 0xc0000076f0, 0xc0009fca50, 0xc000bdda80)
2020-01-06T14:01:42.068-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.4.1/internal/helper/plugin/grpc_provider.go:885 +0x889
2020-01-06T14:01:42.069-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x5231d60, 0xc0000076f0, 0x5c67940, 0xc0009fca50, 0xc000b5faa0, 0x0, 0x5c67940, 0xc0009fca50, 0xc000429c00, 0xbe5)
2020-01-06T14:01:42.069-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.4.1/internal/tfplugin5/tfplugin5.pb.go:3189 +0x21e
2020-01-06T14:01:42.069-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000da000, 0x5c89320, 0xc0004a1c80, 0xc00013d100, 0xc00072b260, 0x89bf3a0, 0x0, 0x0, 0x0)
2020-01-06T14:01:42.069-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:995 +0x467
2020-01-06T14:01:42.069-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: google.golang.org/grpc.(*Server).handleStream(0xc0000da000, 0x5c89320, 0xc0004a1c80, 0xc00013d100, 0x0)
2020-01-06T14:01:42.069-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:1275 +0xd9e
2020-01-06T14:01:42.069-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0003fa9c0, 0xc0000da000, 0x5c89320, 0xc0004a1c80, 0xc00013d100)
2020-01-06T14:01:42.069-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:710 +0xc2
2020-01-06T14:01:42.069-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-01-06T14:01:42.069-0600 [DEBUG] plugin.terraform-provider-aws_v2.43.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:708 +0xa8

We are performing an incorrect type assertion on this line:

https://github.com/terraform-providers/terraform-provider-aws/blob/f56bdef35a07322413b97d06f754a4fe0ee0d6c0/aws/resource_aws_fsx_windows_file_system.go#L410

It should be:

DnsIps:   expandStringSet(data["dns_ips"].(*schema.Set)),

We should be able to reproduce and verify this fix in our acceptance testing by creating a test similar to TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory, except where it also tries to perform an update of dns_ips or more simply the username, e.g.

func TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory_Username(t *testing.T) {
	var filesystem fsx.FileSystem
	resourceName := "aws_fsx_windows_file_system.test"

	resource.ParallelTest(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckFsxWindowsFileSystemDestroy,
		Steps: []resource.TestStep{
			{
				Config: testAccAwsFsxWindowsFileSystemConfigSelfManagedActiveDirectoryUsername("Admin"),
				Check: resource.ComposeTestCheckFunc(
					testAccCheckFsxWindowsFileSystemExists(resourceName, &filesystem),
					resource.TestCheckResourceAttr(resourceName, "self_managed_active_directory.#", "1"),
				),
			},
			{
				ResourceName:      resourceName,
				ImportState:       true,
				ImportStateVerify: true,
				ImportStateVerifyIgnore: []string{
					"security_group_ids",
					"self_managed_active_directory",
					"skip_final_backup",
				},
			},
			{
				Config: testAccAwsFsxWindowsFileSystemConfigSelfManagedActiveDirectoryUsername("Administrator"),
				Check: resource.ComposeTestCheckFunc(
					testAccCheckFsxWindowsFileSystemExists(resourceName, &filesystem),
					resource.TestCheckResourceAttr(resourceName, "self_managed_active_directory.#", "1"),
				),
			},
		},
	})
}

func testAccAwsFsxWindowsFileSystemConfigSelfManagedActiveDirectoryUsername(username string) string {
	return testAccAwsFsxWindowsFileSystemConfigBase() + fmt.Sprintf(`
resource "aws_fsx_windows_file_system" "test" {
  skip_final_backup   = true
  storage_capacity    = 32
  subnet_ids          = ["${aws_subnet.test1.id}"]
  throughput_capacity = 8
  self_managed_active_directory {
    dns_ips     = aws_directory_service_directory.test.dns_ip_addresses
    domain_name = aws_directory_service_directory.test.name
    password    = aws_directory_service_directory.test.password
    username    = %[1]q
  }
}
`, username)
}

Before the code update, it should cause the same panic (NOTE: the testing will leave dangling resources like the Directory Service Directory, FSx Windows File System, etc). After the code update, the testing should pass. 👍

If you or anyone is interested in implementing the above fix, please mention or reach out if you have any questions.

@bflad bflad self-assigned this Apr 1, 2020
bflad added a commit that referenced this issue Apr 2, 2020
…des `self_managed_active_directory` settings

Reference: #11500

Previously:

```
=== CONT  TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory_Username
panic: interface conversion: interface {} is *schema.Set, not []interface {}

goroutine 4434 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.expandFsxSelfManagedActiveDirectoryConfigurationUpdate(0xc000488de0, 0x1, 0x1, 0x5b2f000)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_fsx_windows_file_system.go:413 +0x2d7
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsFsxWindowsFileSystemUpdate(0xc00004ed20, 0x62e3060, 0xc0003c3900, 0x0, 0x0)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_fsx_windows_file_system.go:269 +0x637
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc00099b580, 0xc001cf2cd0, 0xc000ddebe0, 0x62e3060, 0xc0003c3900, 0x6168e01, 0xc001e73760, 0xc001914db0)
	/Users/bflad/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.8.0/helper/schema/resource.go:311 +0x263
```

Output from acceptance testing:

```
--- PASS: TestAccAWSFsxWindowsFileSystem_AutomaticBackupRetentionDays (3063.70s)
--- PASS: TestAccAWSFsxWindowsFileSystem_basic (2915.15s)
--- PASS: TestAccAWSFsxWindowsFileSystem_CopyTagsToBackups (4140.35s)
--- PASS: TestAccAWSFsxWindowsFileSystem_DailyAutomaticBackupStartTime (3034.18s)
--- PASS: TestAccAWSFsxWindowsFileSystem_disappears (3045.25s)
--- PASS: TestAccAWSFsxWindowsFileSystem_KmsKeyId (4148.71s)
--- PASS: TestAccAWSFsxWindowsFileSystem_SecurityGroupIds (4179.82s)
--- PASS: TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory (2905.75s)
--- PASS: TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory_Username (3731.46s)
--- PASS: TestAccAWSFsxWindowsFileSystem_StorageCapacity (4120.68s)
--- PASS: TestAccAWSFsxWindowsFileSystem_Tags (2968.90s)
--- PASS: TestAccAWSFsxWindowsFileSystem_ThroughputCapacity (4056.94s)
--- PASS: TestAccAWSFsxWindowsFileSystem_WeeklyMaintenanceStartTime (3012.74s)
```
@bflad
Copy link
Contributor

bflad commented Apr 2, 2020

Fix submitted: #12630

@bflad bflad added this to the v2.60.0 milestone Apr 28, 2020
bflad added a commit that referenced this issue Apr 28, 2020
…des `self_managed_active_directory` settings (#12630)

Reference: #11500

Previously:

```
=== CONT  TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory_Username
panic: interface conversion: interface {} is *schema.Set, not []interface {}

goroutine 4434 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.expandFsxSelfManagedActiveDirectoryConfigurationUpdate(0xc000488de0, 0x1, 0x1, 0x5b2f000)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_fsx_windows_file_system.go:413 +0x2d7
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsFsxWindowsFileSystemUpdate(0xc00004ed20, 0x62e3060, 0xc0003c3900, 0x0, 0x0)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_fsx_windows_file_system.go:269 +0x637
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc00099b580, 0xc001cf2cd0, 0xc000ddebe0, 0x62e3060, 0xc0003c3900, 0x6168e01, 0xc001e73760, 0xc001914db0)
	/Users/bflad/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.8.0/helper/schema/resource.go:311 +0x263
```

Output from acceptance testing:

```
--- PASS: TestAccAWSFsxWindowsFileSystem_AutomaticBackupRetentionDays (3063.70s)
--- PASS: TestAccAWSFsxWindowsFileSystem_basic (2915.15s)
--- PASS: TestAccAWSFsxWindowsFileSystem_CopyTagsToBackups (4140.35s)
--- PASS: TestAccAWSFsxWindowsFileSystem_DailyAutomaticBackupStartTime (3034.18s)
--- PASS: TestAccAWSFsxWindowsFileSystem_disappears (3045.25s)
--- PASS: TestAccAWSFsxWindowsFileSystem_KmsKeyId (4148.71s)
--- PASS: TestAccAWSFsxWindowsFileSystem_SecurityGroupIds (4179.82s)
--- PASS: TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory (2905.75s)
--- PASS: TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory_Username (3731.46s)
--- PASS: TestAccAWSFsxWindowsFileSystem_StorageCapacity (4120.68s)
--- PASS: TestAccAWSFsxWindowsFileSystem_Tags (2968.90s)
--- PASS: TestAccAWSFsxWindowsFileSystem_ThroughputCapacity (4056.94s)
--- PASS: TestAccAWSFsxWindowsFileSystem_WeeklyMaintenanceStartTime (3012.74s)
```
@bflad
Copy link
Contributor

bflad commented Apr 28, 2020

The fix for this has been merged and will release with version 2.60.0 of the Terraform AWS Provider, later this week. 👍

@ghost
Copy link

ghost commented May 1, 2020

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

adamdecaf pushed a commit to adamdecaf/terraform-provider-aws that referenced this issue May 28, 2020
…des `self_managed_active_directory` settings (hashicorp#12630)

Reference: hashicorp#11500

Previously:

```
=== CONT  TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory_Username
panic: interface conversion: interface {} is *schema.Set, not []interface {}

goroutine 4434 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.expandFsxSelfManagedActiveDirectoryConfigurationUpdate(0xc000488de0, 0x1, 0x1, 0x5b2f000)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_fsx_windows_file_system.go:413 +0x2d7
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsFsxWindowsFileSystemUpdate(0xc00004ed20, 0x62e3060, 0xc0003c3900, 0x0, 0x0)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_fsx_windows_file_system.go:269 +0x637
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc00099b580, 0xc001cf2cd0, 0xc000ddebe0, 0x62e3060, 0xc0003c3900, 0x6168e01, 0xc001e73760, 0xc001914db0)
	/Users/bflad/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.8.0/helper/schema/resource.go:311 +0x263
```

Output from acceptance testing:

```
--- PASS: TestAccAWSFsxWindowsFileSystem_AutomaticBackupRetentionDays (3063.70s)
--- PASS: TestAccAWSFsxWindowsFileSystem_basic (2915.15s)
--- PASS: TestAccAWSFsxWindowsFileSystem_CopyTagsToBackups (4140.35s)
--- PASS: TestAccAWSFsxWindowsFileSystem_DailyAutomaticBackupStartTime (3034.18s)
--- PASS: TestAccAWSFsxWindowsFileSystem_disappears (3045.25s)
--- PASS: TestAccAWSFsxWindowsFileSystem_KmsKeyId (4148.71s)
--- PASS: TestAccAWSFsxWindowsFileSystem_SecurityGroupIds (4179.82s)
--- PASS: TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory (2905.75s)
--- PASS: TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory_Username (3731.46s)
--- PASS: TestAccAWSFsxWindowsFileSystem_StorageCapacity (4120.68s)
--- PASS: TestAccAWSFsxWindowsFileSystem_Tags (2968.90s)
--- PASS: TestAccAWSFsxWindowsFileSystem_ThroughputCapacity (4056.94s)
--- PASS: TestAccAWSFsxWindowsFileSystem_WeeklyMaintenanceStartTime (3012.74s)
```
@ghost
Copy link

ghost commented May 29, 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 and limited conversation to collaborators May 29, 2020
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. crash Results from or addresses a Terraform crash or kernel panic. service/fsx Issues and PRs that pertain to the fsx service.
Projects
None yet
2 participants