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

New Resource: aws_gamelift_fleet #3327

Merged
merged 2 commits into from
Feb 13, 2018
Merged

New Resource: aws_gamelift_fleet #3327

merged 2 commits into from
Feb 13, 2018

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Feb 12, 2018

Test results

=== RUN   TestAccAWSGameliftFleet_basic
--- PASS: TestAccAWSGameliftFleet_basic (1111.72s)
=== RUN   TestAccAWSGameliftFleet_allFields
--- PASS: TestAccAWSGameliftFleet_allFields (1262.53s)

Related: #2546

@radeksimko radeksimko added new-resource Introduces a new resource. service/gamelift Issues and PRs that pertain to the gamelift service. labels Feb 12, 2018
@ghost ghost added the size/XXL Managed by automation to categorize the size of a PR. label Feb 12, 2018
@bflad bflad self-requested a review February 12, 2018 11:27
@bflad bflad added this to the v1.10.0 milestone Feb 12, 2018
Copy link
Contributor

@bflad bflad left a 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) {
Copy link
Contributor

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?

Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"TCP", "UDP",
Copy link
Contributor

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)
Copy link
Contributor

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},
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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)
Copy link
Contributor

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"),
Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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`.
Copy link
Contributor

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.
Copy link
Contributor

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": {
Copy link
Contributor

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,

@bflad
Copy link
Contributor

bflad commented Feb 12, 2018

Let me know when you'd like me to give another look! 👀

@ghost ghost added the size/XXL Managed by automation to categorize the size of a PR. label Feb 12, 2018
@radeksimko
Copy link
Member Author

@bflad PTAL

@Hinidu
Copy link
Contributor

Hinidu commented Feb 13, 2018

Do you plan to implement fleet autoscaling policies? It is essential part of the fleet for us and many other developers.

@radeksimko
Copy link
Member Author

@Hinidu supporting autoscaling policy sounds like a good idea, although it should certainly be a separate resource, e.g. aws_gamelift_autoscaling_policy which maps to these API methods:

It's not on my near-term plan though, so I think we'd be happy to accept PRs for such resource.

@Hinidu
Copy link
Contributor

Hinidu commented Feb 13, 2018

@radeksimko got it. I hope I will find some time to make these PRs 🙂

Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

This looks great! 🚀 🚢 ⛵️

@radeksimko radeksimko merged commit b1a437e into master Feb 13, 2018
@radeksimko radeksimko deleted the f-gamelift-fleet branch February 13, 2018 13:49
@bflad
Copy link
Contributor

bflad commented Feb 27, 2018

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.

@ghost
Copy link

ghost commented Apr 7, 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 Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-resource Introduces a new resource. service/gamelift Issues and PRs that pertain to the gamelift service. size/XXL Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants