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

Add fleet_type option for Gamelift fleets. #3809 #8234

Merged
merged 4 commits into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions aws/resource_aws_gamelift_fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ func resourceAwsGameliftFleet() *schema.Resource {
Required: true,
ForceNew: true,
},
"fleet_type": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: gamelift.FleetTypeOnDemand,
ValidateFunc: validation.StringInSlice([]string{
gamelift.FleetTypeOnDemand,
gamelift.FleetTypeSpot,
}, false),
},
"name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -193,6 +203,9 @@ func resourceAwsGameliftFleetCreate(d *schema.ResourceData, meta interface{}) er
if v, ok := d.GetOk("description"); ok {
input.Description = aws.String(v.(string))
}
if v, ok := d.GetOk("fleet_type"); ok {
input.FleetType = aws.String(v.(string))
}
if v, ok := d.GetOk("ec2_inbound_permission"); ok {
input.EC2InboundPermissions = expandGameliftIpPermissions(v.([]interface{}))
}
Expand Down Expand Up @@ -308,6 +321,7 @@ func resourceAwsGameliftFleetRead(d *schema.ResourceData, meta interface{}) erro
d.Set("log_paths", aws.StringValueSlice(fleet.LogPaths))
d.Set("metric_groups", flattenStringList(fleet.MetricGroups))
d.Set("name", fleet.Name)
d.Set("fleet_type", fleet.FleetType)
d.Set("instance_role_arn", fleet.InstanceRoleArn)
d.Set("new_game_session_protection_policy", fleet.NewGameSessionProtectionPolicy)
d.Set("operating_system", fleet.OperatingSystem)
Expand Down
5 changes: 5 additions & 0 deletions aws/resource_aws_gamelift_fleet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ func TestAccAWSGameliftFleet_allFields(t *testing.T) {
resource.TestCheckResourceAttrSet("aws_gamelift_fleet.test", "build_id"),
resource.TestMatchResourceAttr("aws_gamelift_fleet.test", "arn", regexp.MustCompile(`^arn:[^:]+:gamelift:[^:]+:[^:]+:.+$`)),
resource.TestCheckResourceAttr("aws_gamelift_fleet.test", "ec2_instance_type", "c4.large"),
resource.TestCheckResourceAttr("aws_gamelift_fleet.test", "fleet_type", "ON_DEMAND"),
resource.TestCheckResourceAttr("aws_gamelift_fleet.test", "name", fleetName),
resource.TestCheckResourceAttr("aws_gamelift_fleet.test", "description", desc),
resource.TestCheckResourceAttr("aws_gamelift_fleet.test", "ec2_inbound_permission.#", "3"),
Expand Down Expand Up @@ -396,6 +397,7 @@ func TestAccAWSGameliftFleet_allFields(t *testing.T) {
resource.TestCheckResourceAttrSet("aws_gamelift_fleet.test", "build_id"),
resource.TestMatchResourceAttr("aws_gamelift_fleet.test", "arn", regexp.MustCompile(`^arn:[^:]+:gamelift:[^:]+:[^:]+:.+$`)),
resource.TestCheckResourceAttr("aws_gamelift_fleet.test", "ec2_instance_type", "c4.large"),
resource.TestCheckResourceAttr("aws_gamelift_fleet.test", "fleet_type", "ON_DEMAND"),
resource.TestCheckResourceAttr("aws_gamelift_fleet.test", "name", fleetName),
resource.TestCheckResourceAttr("aws_gamelift_fleet.test", "description", desc),
resource.TestCheckResourceAttr("aws_gamelift_fleet.test", "ec2_inbound_permission.#", "3"),
Expand Down Expand Up @@ -556,6 +558,7 @@ resource "aws_gamelift_fleet" "test" {
name = "%s"
description = "%s"
instance_role_arn = "${aws_iam_role.test.arn}"
fleet_type = "ON_DEMAND"
Copy link
Contributor

Choose a reason for hiding this comment

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

We should ensure existing configurations do not show a difference by removing these additions to the test configurations. The resource.TestCheckResourceAttr() additions above are okay. 👍


ec2_inbound_permission {
from_port = 8080
Expand Down Expand Up @@ -611,9 +614,11 @@ func testAccAWSGameliftFleetAllFieldsUpdatedConfig(fleetName, desc, launchPath s
resource "aws_gamelift_fleet" "test" {
build_id = "${aws_gamelift_build.test.id}"
ec2_instance_type = "c4.large"

name = "%s"
description = "%s"
instance_role_arn = "${aws_iam_role.test.arn}"
fleet_type = "ON_DEMAND"

ec2_inbound_permission {
from_port = 8888
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/gamelift_fleet.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Provides a Gamelift Fleet resource.
resource "aws_gamelift_fleet" "example" {
build_id = "${aws_gamelift_build.example.id}"
ec2_instance_type = "t2.micro"
fleet_type = "ON_DEMAND"
name = "example-fleet-name"

runtime_configuration {
Expand All @@ -35,6 +36,7 @@ The following arguments are supported:
* `description` - (Optional) Human-readable description of the fleet.
* `ec2_inbound_permission` - (Optional) Range of IP addresses and port settings that permit inbound traffic to access server processes running on the fleet. See below.
* `ec2_instance_type` - (Required) Name of an EC2 instance type. e.g. `t2.micro`
* `fleet_type` - (Optional) Type of fleet. This value must be `ON_DEMAND` or `SPOT`. Defaults to `ON_DEMAND`.
* `instance_role_arn` - (Optional) ARN of an IAM role that instances in the fleet can assume.
* `metric_groups` - (Optional) List of names of metric groups to add this fleet to. A metric group tracks metrics across all fleets in the group. Defaults to `default`.
* `name` - (Required) The name of the fleet.
Expand Down