From c7ab68b26b8c2a2c75d1becc6d60432f381cef83 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Fri, 10 Apr 2020 22:33:51 +0300 Subject: [PATCH 1/7] add import support --- aws/resource_aws_spot_fleet_request.go | 24 ++- aws/resource_aws_spot_fleet_request_test.go | 156 ++++++++++++++++++ .../docs/r/spot_fleet_request.html.markdown | 8 + 3 files changed, 187 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_spot_fleet_request.go b/aws/resource_aws_spot_fleet_request.go index 110198d2ead7..5e7b2e48f1e0 100644 --- a/aws/resource_aws_spot_fleet_request.go +++ b/aws/resource_aws_spot_fleet_request.go @@ -22,7 +22,9 @@ func resourceAwsSpotFleetRequest() *schema.Resource { Read: resourceAwsSpotFleetRequestRead, Delete: resourceAwsSpotFleetRequestDelete, Update: resourceAwsSpotFleetRequestUpdate, - + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(10 * time.Minute), Delete: schema.DefaultTimeout(5 * time.Minute), @@ -1202,6 +1204,26 @@ func resourceAwsSpotFleetRequestRead(d *schema.ResourceData, meta interface{}) e } } + if config.LoadBalancersConfig != nil { + lbConf := config.LoadBalancersConfig + + if lbConf.ClassicLoadBalancersConfig != nil { + flatLbs := make([]*string, 0) + for _, lb := range lbConf.ClassicLoadBalancersConfig.ClassicLoadBalancers { + flatLbs = append(flatLbs, lb.Name) + } + d.Set("load_balancers", flattenStringSet(flatLbs)) + } + + if lbConf.TargetGroupsConfig != nil { + flatTgs := make([]*string, 0) + for _, tg := range lbConf.TargetGroupsConfig.TargetGroups { + flatTgs = append(flatTgs, tg.Arn) + } + d.Set("target_group_arns", flattenStringSet(flatTgs)) + } + } + return nil } diff --git a/aws/resource_aws_spot_fleet_request_test.go b/aws/resource_aws_spot_fleet_request_test.go index 8ab04a02c0fc..1c924aaeb8e5 100644 --- a/aws/resource_aws_spot_fleet_request_test.go +++ b/aws/resource_aws_spot_fleet_request_test.go @@ -78,6 +78,12 @@ func TestAccAWSSpotFleetRequest_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -102,6 +108,12 @@ func TestAccAWSSpotFleetRequest_tags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, { Config: testAccAWSSpotFleetRequestConfigTags2(rName, validUntil, "key1", "value1updated", "key2", "value2", rInt), Check: resource.ComposeAggregateTestCheckFunc( @@ -144,6 +156,12 @@ func TestAccAWSSpotFleetRequest_associatePublicIpAddress(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_specification.24370212.associate_public_ip_address", "true"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -313,6 +331,12 @@ func TestAccAWSSpotFleetRequest_instanceInterruptionBehavior(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "instance_interruption_behaviour", "stop"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -337,6 +361,12 @@ func TestAccAWSSpotFleetRequest_fleetType(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "fleet_type", "request"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -361,6 +391,12 @@ func TestAccAWSSpotFleetRequest_iamInstanceProfileArn(t *testing.T) { testAccCheckAWSSpotFleetRequest_IamInstanceProfileArn(&sfr), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -386,6 +422,12 @@ func TestAccAWSSpotFleetRequest_changePriceForcesNewRequest(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_specification.#", "1"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, { Config: testAccAWSSpotFleetRequestConfigChangeSpotBidPrice(rName, rInt, validUntil), Check: resource.ComposeAggregateTestCheckFunc( @@ -420,6 +462,12 @@ func TestAccAWSSpotFleetRequest_updateTargetCapacity(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "target_capacity", "2"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, { Config: testAccAWSSpotFleetRequestConfigTargetCapacity(rName, rInt, validUntil), Check: resource.ComposeAggregateTestCheckFunc( @@ -459,6 +507,12 @@ func TestAccAWSSpotFleetRequest_updateExcessCapacityTerminationPolicy(t *testing resource.TestCheckResourceAttr(resourceName, "excess_capacity_termination_policy", "Default"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, { Config: testAccAWSSpotFleetRequestConfigExcessCapacityTermination(rName, rInt, validUntil), Check: resource.ComposeAggregateTestCheckFunc( @@ -490,6 +544,12 @@ func TestAccAWSSpotFleetRequest_lowestPriceAzOrSubnetInRegion(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_specification.#", "1"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -516,6 +576,12 @@ func TestAccAWSSpotFleetRequest_lowestPriceAzInGivenList(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_specification.19404370.availability_zone", "us-west-2b"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -540,6 +606,12 @@ func TestAccAWSSpotFleetRequest_lowestPriceSubnetInGivenList(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_specification.#", "2"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -568,6 +640,12 @@ func TestAccAWSSpotFleetRequest_multipleInstanceTypesInSameAz(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_specification.590403189.availability_zone", "us-west-2a"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -615,6 +693,12 @@ func TestAccAWSSpotFleetRequest_multipleInstanceTypesInSameSubnet(t *testing.T) resource.TestCheckResourceAttr(resourceName, "launch_specification.#", "2"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -644,6 +728,12 @@ func TestAccAWSSpotFleetRequest_overriddingSpotPrice(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_specification.1991689378.instance_type", "m1.small"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -668,6 +758,12 @@ func TestAccAWSSpotFleetRequest_withoutSpotPrice(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_specification.#", "2"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -693,6 +789,12 @@ func TestAccAWSSpotFleetRequest_diversifiedAllocation(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "allocation_strategy", "diversified"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -719,6 +821,12 @@ func TestAccAWSSpotFleetRequest_multipleInstancePools(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "instance_pools_to_use_count", "2"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -762,6 +870,12 @@ func TestAccAWSSpotFleetRequest_withWeightedCapacity(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_specification.590403189.instance_type", "m3.large"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -785,6 +899,12 @@ func TestAccAWSSpotFleetRequest_withEBSDisk(t *testing.T) { testAccCheckAWSSpotFleetRequest_EBSAttributes(&config), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -807,6 +927,12 @@ func TestAccAWSSpotFleetRequest_LaunchSpecification_EbsBlockDevice_KmsKeyId(t *t testAccCheckAWSSpotFleetRequestExists(resourceName, &config), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -829,6 +955,12 @@ func TestAccAWSSpotFleetRequest_LaunchSpecification_RootBlockDevice_KmsKeyId(t * testAccCheckAWSSpotFleetRequestExists(resourceName, &config), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -854,6 +986,12 @@ func TestAccAWSSpotFleetRequest_withTags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_specification.24370212.tags.Second", "Terraform"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -878,6 +1016,12 @@ func TestAccAWSSpotFleetRequest_placementTenancyAndGroup(t *testing.T) { testAccCheckAWSSpotFleetRequest_PlacementAttributes(&sfr, rName), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -903,6 +1047,12 @@ func TestAccAWSSpotFleetRequest_WithELBs(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "load_balancers.#", "1"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -927,6 +1077,12 @@ func TestAccAWSSpotFleetRequest_WithTargetGroups(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "target_group_arns.#", "1"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } diff --git a/website/docs/r/spot_fleet_request.html.markdown b/website/docs/r/spot_fleet_request.html.markdown index 553beb5a3733..ed7230229a29 100644 --- a/website/docs/r/spot_fleet_request.html.markdown +++ b/website/docs/r/spot_fleet_request.html.markdown @@ -243,3 +243,11 @@ In addition to all arguments above, the following attributes are exported: * `id` - The Spot fleet request ID * `spot_request_state` - The state of the Spot fleet request. + +## Import + +Spot Fleet Requests can be imported using `id`, e.g. + +``` +$ terraform import aw_spot_fleet_request.fleet sfr-005e9ec8-5546-4c31-b317-31a62325411e +``` \ No newline at end of file From fca6993b8493aa728f4161bfae6a28cc8af031c0 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Fri, 10 Apr 2020 22:46:09 +0300 Subject: [PATCH 2/7] fmt fix --- aws/resource_aws_spot_fleet_request_test.go | 156 ++++++++++---------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/aws/resource_aws_spot_fleet_request_test.go b/aws/resource_aws_spot_fleet_request_test.go index 1c924aaeb8e5..6081f2b1f703 100644 --- a/aws/resource_aws_spot_fleet_request_test.go +++ b/aws/resource_aws_spot_fleet_request_test.go @@ -79,9 +79,9 @@ func TestAccAWSSpotFleetRequest_basic(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -109,9 +109,9 @@ func TestAccAWSSpotFleetRequest_tags(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, { @@ -157,9 +157,9 @@ func TestAccAWSSpotFleetRequest_associatePublicIpAddress(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -332,9 +332,9 @@ func TestAccAWSSpotFleetRequest_instanceInterruptionBehavior(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -362,9 +362,9 @@ func TestAccAWSSpotFleetRequest_fleetType(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -392,9 +392,9 @@ func TestAccAWSSpotFleetRequest_iamInstanceProfileArn(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -423,9 +423,9 @@ func TestAccAWSSpotFleetRequest_changePriceForcesNewRequest(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, { @@ -463,9 +463,9 @@ func TestAccAWSSpotFleetRequest_updateTargetCapacity(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, { @@ -508,9 +508,9 @@ func TestAccAWSSpotFleetRequest_updateExcessCapacityTerminationPolicy(t *testing ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, { @@ -545,9 +545,9 @@ func TestAccAWSSpotFleetRequest_lowestPriceAzOrSubnetInRegion(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -577,9 +577,9 @@ func TestAccAWSSpotFleetRequest_lowestPriceAzInGivenList(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -607,9 +607,9 @@ func TestAccAWSSpotFleetRequest_lowestPriceSubnetInGivenList(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -641,9 +641,9 @@ func TestAccAWSSpotFleetRequest_multipleInstanceTypesInSameAz(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -694,9 +694,9 @@ func TestAccAWSSpotFleetRequest_multipleInstanceTypesInSameSubnet(t *testing.T) ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -729,9 +729,9 @@ func TestAccAWSSpotFleetRequest_overriddingSpotPrice(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -759,9 +759,9 @@ func TestAccAWSSpotFleetRequest_withoutSpotPrice(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -790,9 +790,9 @@ func TestAccAWSSpotFleetRequest_diversifiedAllocation(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -822,9 +822,9 @@ func TestAccAWSSpotFleetRequest_multipleInstancePools(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -871,9 +871,9 @@ func TestAccAWSSpotFleetRequest_withWeightedCapacity(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -900,9 +900,9 @@ func TestAccAWSSpotFleetRequest_withEBSDisk(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -928,9 +928,9 @@ func TestAccAWSSpotFleetRequest_LaunchSpecification_EbsBlockDevice_KmsKeyId(t *t ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -956,9 +956,9 @@ func TestAccAWSSpotFleetRequest_LaunchSpecification_RootBlockDevice_KmsKeyId(t * ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -987,9 +987,9 @@ func TestAccAWSSpotFleetRequest_withTags(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -1017,9 +1017,9 @@ func TestAccAWSSpotFleetRequest_placementTenancyAndGroup(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -1048,9 +1048,9 @@ func TestAccAWSSpotFleetRequest_WithELBs(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, @@ -1078,9 +1078,9 @@ func TestAccAWSSpotFleetRequest_WithTargetGroups(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, }, }, From 758d90cc2c8e9c9eab0200684dbc83c805c0a57b Mon Sep 17 00:00:00 2001 From: Ilia Lazebnik Date: Mon, 27 Apr 2020 21:04:55 +0300 Subject: [PATCH 3/7] fix typo Co-Authored-By: angie pinilla --- website/docs/r/spot_fleet_request.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/spot_fleet_request.html.markdown b/website/docs/r/spot_fleet_request.html.markdown index ed7230229a29..6eea1f59b022 100644 --- a/website/docs/r/spot_fleet_request.html.markdown +++ b/website/docs/r/spot_fleet_request.html.markdown @@ -249,5 +249,5 @@ In addition to all arguments above, the following attributes are exported: Spot Fleet Requests can be imported using `id`, e.g. ``` -$ terraform import aw_spot_fleet_request.fleet sfr-005e9ec8-5546-4c31-b317-31a62325411e -``` \ No newline at end of file +$ terraform import aws_spot_fleet_request.fleet sfr-005e9ec8-5546-4c31-b317-31a62325411e +``` From 0f33994c63226f44cfcfe8f432f97d01df26c72d Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Tue, 28 Apr 2020 10:26:39 +0300 Subject: [PATCH 4/7] rebase import and add to new test cases --- aws/resource_aws_spot_fleet_request_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/aws/resource_aws_spot_fleet_request_test.go b/aws/resource_aws_spot_fleet_request_test.go index 6081f2b1f703..9eb013f51b66 100644 --- a/aws/resource_aws_spot_fleet_request_test.go +++ b/aws/resource_aws_spot_fleet_request_test.go @@ -187,6 +187,12 @@ func TestAccAWSSpotFleetRequest_launchTemplate(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_template_config.#", "1"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -237,6 +243,12 @@ func TestAccAWSSpotFleetRequest_launchTemplateWithOverrides(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_template_config.#", "1"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, }, }) } @@ -262,6 +274,12 @@ func TestAccAWSSpotFleetRequest_launchTemplateToLaunchSpec(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "launch_template_config.#", "1"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"wait_for_fulfillment"}, + }, { Config: testAccAWSSpotFleetRequestConfig(rName, rInt, validUntil), Check: resource.ComposeAggregateTestCheckFunc( From 25a209746b5516e9de883100f7a9a2156274bd74 Mon Sep 17 00:00:00 2001 From: Ilia Lazebnik Date: Tue, 28 Apr 2020 10:40:41 +0300 Subject: [PATCH 5/7] Update aws/resource_aws_spot_fleet_request.go Co-Authored-By: Brian Flad --- aws/resource_aws_spot_fleet_request.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_spot_fleet_request.go b/aws/resource_aws_spot_fleet_request.go index 5e7b2e48f1e0..3b978e4c8a4f 100644 --- a/aws/resource_aws_spot_fleet_request.go +++ b/aws/resource_aws_spot_fleet_request.go @@ -1220,7 +1220,9 @@ func resourceAwsSpotFleetRequestRead(d *schema.ResourceData, meta interface{}) e for _, tg := range lbConf.TargetGroupsConfig.TargetGroups { flatTgs = append(flatTgs, tg.Arn) } - d.Set("target_group_arns", flattenStringSet(flatTgs)) + if err := d.Set("target_group_arns", flattenStringSet(flatTgs)); err != nil { + return fmt.Errorf("error setting target_group_arns: %s", err) + } } } From 122f6b49bfac99f4dc213fdc7f313c356ae3c04e Mon Sep 17 00:00:00 2001 From: Ilia Lazebnik Date: Tue, 28 Apr 2020 10:40:51 +0300 Subject: [PATCH 6/7] Update aws/resource_aws_spot_fleet_request.go Co-Authored-By: Brian Flad --- aws/resource_aws_spot_fleet_request.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_spot_fleet_request.go b/aws/resource_aws_spot_fleet_request.go index 3b978e4c8a4f..2a47c2975473 100644 --- a/aws/resource_aws_spot_fleet_request.go +++ b/aws/resource_aws_spot_fleet_request.go @@ -1212,7 +1212,9 @@ func resourceAwsSpotFleetRequestRead(d *schema.ResourceData, meta interface{}) e for _, lb := range lbConf.ClassicLoadBalancersConfig.ClassicLoadBalancers { flatLbs = append(flatLbs, lb.Name) } - d.Set("load_balancers", flattenStringSet(flatLbs)) + if err := d.Set("load_balancers", flattenStringSet(flatLbs)); err != nil { + return fmt.Errorf("error setting load_balancers: %s", err) + } } if lbConf.TargetGroupsConfig != nil { From be31df24a8530aa911e15ac67405f5b06ee33974 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Tue, 28 Apr 2020 13:32:58 +0300 Subject: [PATCH 7/7] set "instance_pools_to_use_count" in import --- aws/resource_aws_spot_fleet_request.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_spot_fleet_request.go b/aws/resource_aws_spot_fleet_request.go index 2a47c2975473..5639179103c8 100644 --- a/aws/resource_aws_spot_fleet_request.go +++ b/aws/resource_aws_spot_fleet_request.go @@ -23,7 +23,10 @@ func resourceAwsSpotFleetRequest() *schema.Resource { Delete: resourceAwsSpotFleetRequestDelete, Update: resourceAwsSpotFleetRequestUpdate, Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, + State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + d.Set("instance_pools_to_use_count", 1) + return []*schema.ResourceData{d}, nil + }, }, Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(10 * time.Minute),