> **Experimental**
>
> `@aws-cdk/aws-gamelift-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# MatchmakingRuleSet

Creates a new rule set for FlexMatch matchmaking.

The rule set determines the two key elements of a match: your game's team structure and size, and how to group players together for the best possible match.

For example, a rule set might describe a match like this:
 - Create a match with two teams of five players each, one team is the defenders and the other team the invaders.
 - A team can have novice and experienced players, but the average skill of the two teams must be within 10 points of each other.
 - If no match is made after 30 seconds, gradually relax the skill requirements.

Rule sets must be defined in the same Region as the matchmaking configuration they are used with.

Extends: Construct › Resource › MatchmakingRuleSetBase › MatchmakingRuleSet
Implements: IMatchmakingRuleSet, IResource, IEnvironmentAware, IConstruct, IDependable

- Stability: [Experimental](/cdk/api/stability.html)
- CloudFormation: [`AWS::GameLift::MatchmakingRuleSet`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-gamelift-matchmakingruleset.html)
- L1 type: [`CfnMatchmakingRuleSet`](/cdk/api/v2/docs/aws-cdk-lib.aws_gamelift.CfnMatchmakingRuleSet.html)
- Source: [`lib/matchmaking-ruleset.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0-alpha.0/packages/@aws-cdk/aws-gamelift-alpha/lib/matchmaking-ruleset.ts#L139)

## Example

```ts
new gamelift.MatchmakingRuleSet(this, 'RuleSet', {
  matchmakingRuleSetName: 'my-test-ruleset',
  content: gamelift.RuleSetContent.fromJsonFile(path.join(__dirname, 'my-ruleset', 'ruleset.json')),
});
```

## Initializer

```ts
new MatchmakingRuleSet(scope: Construct, id: string, props: MatchmakingRuleSetProps)
```

## Construct Props

- `content`: [RuleSetContent](/cdk/api/v2/docs/@aws-cdk_aws-gamelift-alpha.RuleSetContent.html) (required) — A collection of matchmaking rules.

- `matchmakingRuleSetName`: string (required) — A unique identifier for the matchmaking rule set.

  A matchmaking configuration identifies the rule set it uses by this name value.

  Note: the rule set name is different from the optional name field in the rule set body

## Properties

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) (required) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `matchmakingRuleSetArn`: string (required) — The ARN of the ruleSet.

- `matchmakingRuleSetName`: string (required) — The unique name of the ruleSet.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) (required) — The tree node.

- `PROPERTY_INJECTION_ID`: string (required) (static) — Uniquely identifies this class.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) (required) — The stack in which this resource is defined.

## Methods

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `fromMatchmakingRuleSetArn(scope: Construct, id: string, matchmakingRuleSetArn: string): IMatchmakingRuleSet` (static) — Import a ruleSet into CDK using its ARN.

- `fromMatchmakingRuleSetAttributes(scope: Construct, id: string, attrs: MatchmakingRuleSetAttributes): IMatchmakingRuleSet` (static) — Import an existing matchmaking ruleSet from its attributes.

- `fromMatchmakingRuleSetName(scope: Construct, id: string, matchmakingRuleSetName: string): IMatchmakingRuleSet` (static) — Import a ruleSet into CDK using its name.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `metric(metricName: string, props?: MetricOptions): Metric` — Return the given named metric for this matchmaking ruleSet.

- `metricRuleEvaluationsFailed(props?: MetricOptions): Metric` — Rule evaluations during matchmaking that failed since the last report.

  This metric is limited to the top 50 rules.

- `metricRuleEvaluationsPassed(props?: MetricOptions): Metric` — Rule evaluations during the matchmaking process that passed since the last report.

  This metric is limited to the top 50 rules.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
