-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
New Resource: aws_gamelift_fleet #3327
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some initial comments -- let me know if you have any questions! 🚀
// Location found from CloudTrail event after finishing tutorial | ||
// e.g. https://us-west-2.console.aws.amazon.com/gamelift/home?region=us-west-2#/r/fleets/sample | ||
func testAccAWSGameliftSampleGameLocation(region string) (*gamelift.S3Location, error) { | ||
func testAccAWSGameliftSampleGameLocation(region string) (*testAccGameliftGame, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick: Maybe this function should be renamed without Location (since it has more delicious information) and optionally moved to a "top level" file aws/resource_aws_gamelift_test.go since it spans multiple resources?
aws/resource_aws_gamelift_fleet.go
Outdated
Type: schema.TypeString, | ||
Required: true, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
"TCP", "UDP", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: You'll be happy to know there are SDK constants for these 😛
gamelift.IpProtocolTcp, gamelift.IpProtocolUdp
} | ||
|
||
log.Printf("[INFO] Creating Gamelift Fleet: %s", input) | ||
out, err := conn.CreateFleet(&input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad if we haven't run into eventual consistency issues with BuildId
😄
The build must have been successfully uploaded to Amazon GameLift and be in a READY status.
gamelift.FleetStatusNew, | ||
gamelift.FleetStatusValidating, | ||
}, | ||
Target: []string{gamelift.FleetStatusActive}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Should we try to catch gamelift.FleetStatusError
as a target or in the refresh function to put a better message than the Terraform unexpected state one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think we provide as much details as we can in such case. I'm intentionally not catching FleetStatusError
and let it fall through as error, so I can catch it below and ask for reasons of the state.
We also save some API calls that way since we don't ask for failures with each retry, but only when we know things have failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay that makes sense, and is pretty awesome. 👍
log.Printf("[WARN] Failed to poll fleet failures: %s", fErr) | ||
} | ||
if len(events) > 0 { | ||
return fmt.Errorf("%s Recent failures:\n%+v", err, events) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty awesome 👍
Config: testAccAWSGameliftFleetBasicConfig(fleetName, launchPath, params, buildName, bucketName, key, roleArn), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSGameliftFleetExists("aws_gamelift_fleet.test", &conf), | ||
resource.TestCheckResourceAttrSet("aws_gamelift_fleet.test", "build_id"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing arn
attribute check:
resource.TestMatchResourceAttr("aws_gamelift_fleet.test", "arn", regexp.MustCompile(`^arn:[^:]+:gamelift:[^:]+:[^:]+:.+$`))
|
||
attributes := out.FleetAttributes | ||
|
||
if len(attributes) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check its status for gamelift.FleetStatusDeleting
or gamelift.FleetStatusTerminated
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitForGameliftFleetToBeDeleted
should guarantee that we don't as the fleet should be completely gone by this time. If it's not I'd rather treat that as bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, I missed this when looking at waitForGameliftFleetToBeDeleted
- we're going for zero returned results instead of just gamelift.FleetStatusTerminated
status. I thought you'd be getting the one result with the terminated status 👍
* `name` - (Required) The name of the fleet. | ||
* `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. | ||
* `metric_groups` - (Optional) Name of a metric group to add this fleet to. A metric group tracks metrics across all fleets in the group. Defaults to `default`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List of names
to match schema and API, but max of one 👍
* `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. | ||
* `metric_groups` - (Optional) Name of a metric group to add this fleet to. A metric group tracks metrics across all fleets in the group. Defaults to `default`. | ||
* `new_game_session_protection_policy` - (Optional) Game session protection policy to apply to all instances in this fleet. e.g. `FullProtection`. Defaults to `NoProtection`. | ||
* `resource_creation_limit_policy` - (Optional) Policy that limits the number of game sessions an individual player can create over a span of time for this fleet. sSee below. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo 🕶 : sSee
Required: true, | ||
ValidateFunc: validation.IntBetween(1, 60000), | ||
}, | ||
"ip_range": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can validate this with ValidateFunc: validateCIDRNetworkAddress,
Let me know when you'd like me to give another look! 👀 |
@bflad PTAL |
Do you plan to implement fleet autoscaling policies? It is essential part of the fleet for us and many other developers. |
@Hinidu supporting autoscaling policy sounds like a good idea, although it should certainly be a separate resource, e.g.
It's not on my near-term plan though, so I think we'd be happy to accept PRs for such resource. |
@radeksimko got it. I hope I will find some time to make these PRs 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! 🚀 🚢 ⛵️
This has been released in version 1.10.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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! |
Test results
Related: #2546