-
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_build #2843
Conversation
@radeksimko can't this zip be hosted on a public S3 bucket and then downloaded as part of the test? |
Ideally I'd like the whole test suite to be self-sustainable, not relying on precisely named files in a precisely named S3 bucket. It makes the test a bit fragile. |
This is the contents of the ZIP file:
where the last binary (which was downloaded from MSFT's website per linked tutorial) in the list occupies the majority of the space. This leads me to a conclusion that we can't unfortunately make it much smaller. To put this into context here's usage of the whole repo:
which has close to 70MB. It is unfortunate, but IMO not a huge deal and more importantly I can't think of a better solution (other than what was mentioned by @stack72 above). |
Starting to take a look at this now. At first glance through the comments above, I think I would also prefer we don't add "large" binaries to the repository unless absolutely necessary, but I have not dug into options/caveats here. Incurring additional MBs of Git download for everyone developing on the repository (versus developing the specific resource that requires it) is not friendly for folks with poor internet connections. I think in the worst case we could .gitignore the file location and |
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.
Overall this is looking pretty darn good. I left some questions/nitpicks but nothing major other than how to handle the "large" binary.
Passes for me in its current state:
make testacc TEST=./aws TESTARGS='-run=TestAccAWSGameliftBuild'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSGameliftBuild -timeout 120m
=== RUN TestAccAWSGameliftBuild_basic
--- PASS: TestAccAWSGameliftBuild_basic (66.44s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 66.486s
return 42, "", err | ||
} | ||
|
||
return out, *out.Build.Status, nil |
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 return a friendlier error message when the status is FAILED
instead of the generic resource.StateChangeConf
one for unknown status? API docs say:
FAILED -- The game build upload failed. You cannot create new fleets for this build.
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.
Well, I'd normally opt in for providing more context if there was more context - e.g. any event feed we can pull the context (reasons of failure) from, but I think in this case the error message is more or less equivalent. It still doesn't tell you why things have failed, unfortunately.
Required: true, | ||
ValidateFunc: validation.StringLenBetween(1, 1024), | ||
}, | ||
"operating_system": { |
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: We can validate this at plan time (and maybe should since its spelled out in the docs):
func validateGameliftOperatingSystem(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
operatingSystems := map[string]bool{
gamelift.OperatingSystemAmazonLinux: true,
gamelift.OperatingSystemWindows2012: true,
}
if !operatingSystems[value] {
errors = append(errors, fmt.Errorf("%q must be a valid operating system value: %q", k, value))
}
return
}
) | ||
|
||
func resourceAwsGameliftBuild() *schema.Resource { | ||
return &schema.Resource{ |
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.
Ugh, I see we cannot easily support imports since they do not give back the storage location information.
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.
🤷♂️
_, err := conn.DeleteBuild(&gamelift.DeleteBuildInput{ | ||
BuildId: aws.String(d.Id()), | ||
}) | ||
if err != nil { |
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: We should ignore missing build IDs:
if err != nil {
if isAwsErr(err, gamelift.ErrCodeNotFoundException, "") {
return nil
}
return err
}
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.
We could, but DeleteBuild
doesn't ever return such error if you try deleting build which doesn't exist. 🤷♂️
It just returns 200 OK
.
log.Printf("[INFO] Found %d Gamelift Builds", len(resp.Builds)) | ||
|
||
for _, build := range resp.Builds { | ||
if !strings.HasPrefix(*build.Name, "tf_acc_build_") { |
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: I think we should use a constant here if we're going to expect continuity between the acceptance test naming and the sweeper.
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.
Yeah, that's a good idea.
} | ||
|
||
req := gamelift.DescribeBuildInput{ | ||
BuildId: aws.String(rs.Primary.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.
Do we need to check rs.Primary.ID
beforehand? e.g.
if rs.Primary.ID == "" {
continue
}
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'd say hopefully not? I mean we don't do it in in any CheckDestroy
function for any other acceptance test and I'm hoping core would've already swiped the resource away from state if it doesn't have ID, if not then we have much bigger problems IMO.
), | ||
}, | ||
{ | ||
Config: testAccAWSGameliftBuildBasicUpdateConfig(uBuildName, bucketName, zipPath, roleName, policyName), |
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: I don't think we need the "UpdateConfig" since you've already parameterized the original configuration. 😄
resource.TestCheckResourceAttr("aws_gamelift_build.test", "operating_system", "WINDOWS_2012"), | ||
resource.TestCheckResourceAttr("aws_gamelift_build.test", "storage_location.#", "1"), | ||
resource.TestCheckResourceAttr("aws_gamelift_build.test", "storage_location.0.bucket", bucketName), | ||
resource.TestCheckResourceAttr("aws_gamelift_build.test", "storage_location.0.key", "tf-acc-test-gl-build.zip"), |
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.
Does this need to be parameterized for parallelism/failures?
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.
Not anymore, I found a better way which also eliminates the big ZIP file 😃
050ad21
to
68d6eb5
Compare
It took some effort but I found a way to avoid uploading the big ZIP file to the repo. 😺 I went through the Gamelift tutorial in AWS Console and traced down the location of the Amazon's sample game from CloudTrail. Then I did it for every region Gamelift is currently available in, just to make tests work in potentially any region. |
68d6eb5
to
7c3c448
Compare
}, nil | ||
} | ||
|
||
// Account ID found from CloudTrail event (role ARN) after finishing tutorial in given region |
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.
😍
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.
Huge shoutout for figuring out the sample apps! This very much LGTM now and let's get it in today. 👍 🚀 🎉
make testacc TEST=./aws TESTARGS='-run=TestAccAWSGameliftBuild'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSGameliftBuild -timeout 120m
=== RUN TestAccAWSGameliftBuild_basic
--- PASS: TestAccAWSGameliftBuild_basic (18.81s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 18.862s
This has been released in terraform-provider-aws version 1.8.0. 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! |
I want to take a look into the ZIP file to see if there's any way to bring the size down from 15M, but otherwise this is ready for review.
The ZIP file was basically created by following steps in https://github.com/awslabs/aws-gamelift-sample/blob/master/deployment/deployment.md#gamelift----game-server-build--fleet-creation
and it unfortunately contains a few binaries which practically can't be compressed.
The build resource here practically doesn't require a ZIP file with fully working game, but
aws_gamelift_fleet
(for which I already have a PR in a queue) will.Import
The main reason I decided not to implement import is because
DescribeBuild
doesn't returnstorage_location
which isForceNew
, so having such empty field in the state would result in recreation.Test Results