terraform/builtin/providers/aws/resource_aws_spot_fleet_req...

44 lines
943 B
Go
Raw Normal View History

provider/aws: AWS SpotFleet Requests now works with Subnets and AZs (#8320) * provider/aws: Change Spot Fleet Request to allow a combination of subnet_id and availability_zone Also added a complete set of tests that reflect all of the use cases that Amazon document http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet-examples.html It is important to note there that Terraform will be suggesting that users create multiple launch configurations rather than AWS's version of combing values into CSV based parameters. This will ensure that we are able to enforce the correct state Also note that `associate_public_ip_address` now defaults to `false` - a migration has been included in this PR to migration users of this functionality. This needs to be noted in the changelog. The last part of changing functionality here is waiting for the state of the request to become `active`. Before we get to this state, we cannot guarantee that Amazon have accepted the request or it could have failed validation. ``` % make testacc TEST=./builtin/providers/aws % TESTARGS='-run=TestAccAWSSpotFleetRequest_' % 2 ↵ ==> Checking that code complies with gofmt requirements... /Users/stacko/Code/go/bin/stringer go generate $(go list ./... | grep -v /terraform/vendor/) 2016/08/22 15:44:21 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSSpotFleetRequest_ -timeout 120m === RUN TestAccAWSSpotFleetRequest_changePriceForcesNewRequest --- PASS: TestAccAWSSpotFleetRequest_changePriceForcesNewRequest (133.90s) === RUN TestAccAWSSpotFleetRequest_lowestPriceAzOrSubnetInRegion --- PASS: TestAccAWSSpotFleetRequest_lowestPriceAzOrSubnetInRegion (76.67s) === RUN TestAccAWSSpotFleetRequest_lowestPriceAzInGivenList --- PASS: TestAccAWSSpotFleetRequest_lowestPriceAzInGivenList (75.22s) === RUN TestAccAWSSpotFleetRequest_lowestPriceSubnetInGivenList --- PASS: TestAccAWSSpotFleetRequest_lowestPriceSubnetInGivenList (96.95s) === RUN TestAccAWSSpotFleetRequest_multipleInstanceTypesInSameAz --- PASS: TestAccAWSSpotFleetRequest_multipleInstanceTypesInSameAz (74.44s) === RUN TestAccAWSSpotFleetRequest_multipleInstanceTypesInSameSubnet --- PASS: TestAccAWSSpotFleetRequest_multipleInstanceTypesInSameSubnet (97.82s) === RUN TestAccAWSSpotFleetRequest_overriddingSpotPrice --- PASS: TestAccAWSSpotFleetRequest_overriddingSpotPrice (76.22s) === RUN TestAccAWSSpotFleetRequest_diversifiedAllocation --- PASS: TestAccAWSSpotFleetRequest_diversifiedAllocation (79.81s) === RUN TestAccAWSSpotFleetRequest_withWeightedCapacity --- PASS: TestAccAWSSpotFleetRequest_withWeightedCapacity (77.15s) === RUN TestAccAWSSpotFleetRequest_CannotUseEmptyKeyName --- PASS: TestAccAWSSpotFleetRequest_CannotUseEmptyKeyName (0.00s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 788.184s ``` * Update resource_aws_spot_fleet_request.go
2016-08-24 12:08:46 +02:00
package aws
import (
"testing"
"github.com/hashicorp/terraform/terraform"
)
func TestAWSSpotFleetRequestMigrateState(t *testing.T) {
cases := map[string]struct {
StateVersion int
ID string
Attributes map[string]string
Expected string
Meta interface{}
}{
"v0_1": {
StateVersion: 0,
ID: "some_id",
Attributes: map[string]string{
"associate_public_ip_address": "true",
},
Expected: "false",
},
}
for tn, tc := range cases {
is := &terraform.InstanceState{
ID: tc.ID,
Attributes: tc.Attributes,
}
is, err := resourceAwsSpotFleetRequestMigrateState(
tc.StateVersion, is, tc.Meta)
if err != nil {
t.Fatalf("bad: %s, err: %#v", tn, err)
}
if is.Attributes["associate_public_ip_address"] != tc.Expected {
t.Fatalf("bad Spot Fleet Request Migrate: %s\n\n expected: %s", is.Attributes["associate_public_ip_address"], tc.Expected)
}
}
}