# CfnCodeDeployBlueGreenHook

A CloudFormation Hook for CodeDeploy blue-green ECS deployments.

Extends: Construct › CfnElement › CfnHook › CfnCodeDeployBlueGreenHook
Implements: IConstruct, IDependable

- Source: [`core/lib/cfn-codedeploy-blue-green-hook.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/core/lib/cfn-codedeploy-blue-green-hook.ts#L293)

## Example

```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
const hook: core.CfnHook = cfnTemplate.getHook('MyOutput');

// mutating the hook
declare const myRole: iam.Role;
const codeDeployHook = hook as core.CfnCodeDeployBlueGreenHook;
codeDeployHook.serviceRole = myRole.roleArn;
```

## Initializer

```ts
new CfnCodeDeployBlueGreenHook(scope: Construct, id: string, props: CfnCodeDeployBlueGreenHookProps)
```

## Construct Props

- `additionalOptions`: [CfnCodeDeployBlueGreenAdditionalOptions](/cdk/api/v2/docs/aws-cdk-lib.CfnCodeDeployBlueGreenAdditionalOptions.html) — Additional options for the blue/green deployment.

  **Default:** no additional options

- `applications`: [CfnCodeDeployBlueGreenApplication](/cdk/api/v2/docs/aws-cdk-lib.CfnCodeDeployBlueGreenApplication.html)[] (required) — Properties of the Amazon ECS applications being deployed.

- `lifecycleEventHooks`: [CfnCodeDeployBlueGreenLifecycleEventHooks](/cdk/api/v2/docs/aws-cdk-lib.CfnCodeDeployBlueGreenLifecycleEventHooks.html) — Use lifecycle event hooks to specify a Lambda function that CodeDeploy can call to validate a deployment.

  **Default:** no lifecycle event hooks

  You can use the same function or a different one for deployment lifecycle events.
  Following completion of the validation tests,
  the Lambda `CfnCodeDeployBlueGreenLifecycleEventHooks.afterAllowTraffic`
  function calls back CodeDeploy and delivers a result of 'Succeeded' or 'Failed'.

- `serviceRole`: string (required) — The IAM Role for CloudFormation to use to perform blue-green deployments.

- `trafficRoutingConfig`: [CfnTrafficRoutingConfig](/cdk/api/v2/docs/aws-cdk-lib.CfnTrafficRoutingConfig.html) — Traffic routing configuration settings.

  **Default:** time-based canary traffic shifting, with a 15% step percentage and a five minute bake time

## Properties

- `additionalOptions`: [CfnCodeDeployBlueGreenAdditionalOptions](/cdk/api/v2/docs/aws-cdk-lib.CfnCodeDeployBlueGreenAdditionalOptions.html) — Additional options for the blue/green deployment.

  **Default:** no additional options

- `applications`: [CfnCodeDeployBlueGreenApplication](/cdk/api/v2/docs/aws-cdk-lib.CfnCodeDeployBlueGreenApplication.html)[] — Properties of the Amazon ECS applications being deployed.

- `creationStack`: string[]

- `lifecycleEventHooks`: [CfnCodeDeployBlueGreenLifecycleEventHooks](/cdk/api/v2/docs/aws-cdk-lib.CfnCodeDeployBlueGreenLifecycleEventHooks.html) — Use lifecycle event hooks to specify a Lambda function that CodeDeploy can call to validate a deployment.

  **Default:** no lifecycle event hooks

  You can use the same function or a different one for deployment lifecycle events.
  Following completion of the validation tests,
  the Lambda `CfnCodeDeployBlueGreenLifecycleEventHooks.afterAllowTraffic`
  function calls back CodeDeploy and delivers a result of 'Succeeded' or 'Failed'.

- `logicalId`: string — The logical ID for this CloudFormation stack element.

  The logical ID of the element
  is calculated from the path of the resource node in the construct tree.

  To override this value, use `overrideLogicalId(newLogicalId)`.

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

- `serviceRole`: string — The IAM Role for CloudFormation to use to perform blue-green deployments.

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

  CfnElements must be defined within a stack scope (directly or indirectly).

- `trafficRoutingConfig`: [CfnTrafficRoutingConfig](/cdk/api/v2/docs/aws-cdk-lib.CfnTrafficRoutingConfig.html) — Traffic routing configuration settings.

  **Default:** time-based canary traffic shifting, with a 15% step percentage and a five minute bake time

- `type`: string — The type of the hook (for example, "AWS::CodeDeploy::BlueGreen").

## Methods

- `isCfnElement(x: any): boolean` (static) — Returns `true` if a construct is a stack element (i.e. part of the synthesized cloudformation template).

  Uses duck-typing instead of `instanceof` to allow stack elements from different
  versions of this library to be included in the same stack.

  **Returns:** The construct as a stack element or undefined if it is not a stack element.

- `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`.

- `overrideLogicalId(newLogicalId: string): void` — Overrides the auto-generated logical ID with a specific ID.

  **Parameters**

  - `newLogicalId` — The new logical ID to use for this stack element.

- `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.
