forked from hashicorp/terraform-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r/aws_gamelift_game_server_group: New resource
- Loading branch information
Showing
6 changed files
with
2,060 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package waiter | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/gamelift" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func GameServerGroupState(conn *gamelift.GameLift, gameServerGroupID string) resource.StateRefreshFunc { | ||
return func() (interface{}, string, error) { | ||
output, err := conn.DescribeGameServerGroup(&gamelift.DescribeGameServerGroupInput{ | ||
GameServerGroupName: aws.String(gameServerGroupID), | ||
}) | ||
|
||
if err != nil { | ||
return nil, "", err | ||
} | ||
|
||
if output == nil || output.GameServerGroup == nil { | ||
return nil, "", nil | ||
} | ||
|
||
status := aws.StringValue(output.GameServerGroup.Status) | ||
|
||
if status == gamelift.GameServerGroupStatusError { | ||
return nil, status, errors.New(aws.StringValue(output.GameServerGroup.StatusReason)) | ||
} | ||
|
||
return output.GameServerGroup, status, nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package waiter | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/service/gamelift" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func GameServerGroupActive(conn *gamelift.GameLift, gameServerGroupID string, timeout time.Duration) (*gamelift.GameServerGroup, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Pending: []string{ | ||
gamelift.GameServerGroupStatusNew, | ||
gamelift.GameServerGroupStatusActivating, | ||
}, | ||
Target: []string{ | ||
gamelift.GameServerGroupStatusActive, | ||
}, | ||
Refresh: GameServerGroupState(conn, gameServerGroupID), | ||
Timeout: timeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if v, ok := outputRaw.(*gamelift.GameServerGroup); ok { | ||
return v, err | ||
} | ||
|
||
return nil, err | ||
} | ||
|
||
func GameServerGroupDeleted(conn *gamelift.GameLift, gameServerGroupID string, timeout time.Duration) (*gamelift.GameServerGroup, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Pending: []string{ | ||
gamelift.GameServerGroupStatusDeleteScheduled, | ||
gamelift.GameServerGroupStatusDeleting, | ||
gamelift.GameServerGroupStatusDeleted, | ||
}, | ||
Target: []string{}, | ||
Refresh: GameServerGroupState(conn, gameServerGroupID), | ||
Timeout: timeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if v, ok := outputRaw.(*gamelift.GameServerGroup); ok { | ||
return v, err | ||
} | ||
|
||
return nil, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.