# CfnCodeDeployBlueGreenHookProps

Construction properties of `CfnCodeDeployBlueGreenHook`.

Used as props by: [CfnCodeDeployBlueGreenHook](/cdk/api/v2/docs/aws-cdk-lib.CfnCodeDeployBlueGreenHook.html)

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

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
const cfnCodeDeployBlueGreenHookProps: cdk.CfnCodeDeployBlueGreenHookProps = {
  applications: [{
    ecsAttributes: {
      taskDefinitions: ['taskDefinitions'],
      taskSets: ['taskSets'],
      trafficRouting: {
        prodTrafficRoute: {
          logicalId: 'logicalId',
          type: 'type',
        },
        targetGroups: ['targetGroups'],
        testTrafficRoute: {
          logicalId: 'logicalId',
          type: 'type',
        },
      },
    },
    target: {
      logicalId: 'logicalId',
      type: 'type',
    },
  }],
  serviceRole: 'serviceRole',

  // the properties below are optional
  additionalOptions: {
    terminationWaitTimeInMinutes: 123,
  },
  lifecycleEventHooks: {
    afterAllowTestTraffic: 'afterAllowTestTraffic',
    afterAllowTraffic: 'afterAllowTraffic',
    afterInstall: 'afterInstall',
    beforeAllowTraffic: 'beforeAllowTraffic',
    beforeInstall: 'beforeInstall',
  },
  trafficRoutingConfig: {
    type: cdk.CfnTrafficRoutingType.ALL_AT_ONCE,

    // the properties below are optional
    timeBasedCanary: {
      bakeTimeMins: 123,
      stepPercentage: 123,
    },
    timeBasedLinear: {
      bakeTimeMins: 123,
      stepPercentage: 123,
    },
  },
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk

cfn_code_deploy_blue_green_hook_props = cdk.CfnCodeDeployBlueGreenHookProps(
    applications=[cdk.CfnCodeDeployBlueGreenApplication(
        ecs_attributes=cdk.CfnCodeDeployBlueGreenEcsAttributes(
            task_definitions=["taskDefinitions"],
            task_sets=["taskSets"],
            traffic_routing=cdk.CfnTrafficRouting(
                prod_traffic_route=cdk.CfnTrafficRoute(
                    logical_id="logicalId",
                    type="type"
                ),
                target_groups=["targetGroups"],
                test_traffic_route=cdk.CfnTrafficRoute(
                    logical_id="logicalId",
                    type="type"
                )
            )
        ),
        target=cdk.CfnCodeDeployBlueGreenApplicationTarget(
            logical_id="logicalId",
            type="type"
        )
    )],
    service_role="serviceRole",

    # the properties below are optional
    additional_options=cdk.CfnCodeDeployBlueGreenAdditionalOptions(
        termination_wait_time_in_minutes=123
    ),
    lifecycle_event_hooks=cdk.CfnCodeDeployBlueGreenLifecycleEventHooks(
        after_allow_test_traffic="afterAllowTestTraffic",
        after_allow_traffic="afterAllowTraffic",
        after_install="afterInstall",
        before_allow_traffic="beforeAllowTraffic",
        before_install="beforeInstall"
    ),
    traffic_routing_config=cdk.CfnTrafficRoutingConfig(
        type=cdk.CfnTrafficRoutingType.ALL_AT_ONCE,

        # the properties below are optional
        time_based_canary=cdk.CfnTrafficRoutingTimeBasedCanary(
            bake_time_mins=123,
            step_percentage=123
        ),
        time_based_linear=cdk.CfnTrafficRoutingTimeBasedLinear(
            bake_time_mins=123,
            step_percentage=123
        )
    )
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;

CfnCodeDeployBlueGreenHookProps cfnCodeDeployBlueGreenHookProps = CfnCodeDeployBlueGreenHookProps.builder()
        .applications(List.of(CfnCodeDeployBlueGreenApplication.builder()
                .ecsAttributes(CfnCodeDeployBlueGreenEcsAttributes.builder()
                        .taskDefinitions(List.of("taskDefinitions"))
                        .taskSets(List.of("taskSets"))
                        .trafficRouting(CfnTrafficRouting.builder()
                                .prodTrafficRoute(CfnTrafficRoute.builder()
                                        .logicalId("logicalId")
                                        .type("type")
                                        .build())
                                .targetGroups(List.of("targetGroups"))
                                .testTrafficRoute(CfnTrafficRoute.builder()
                                        .logicalId("logicalId")
                                        .type("type")
                                        .build())
                                .build())
                        .build())
                .target(CfnCodeDeployBlueGreenApplicationTarget.builder()
                        .logicalId("logicalId")
                        .type("type")
                        .build())
                .build()))
        .serviceRole("serviceRole")

        // the properties below are optional
        .additionalOptions(CfnCodeDeployBlueGreenAdditionalOptions.builder()
                .terminationWaitTimeInMinutes(123)
                .build())
        .lifecycleEventHooks(CfnCodeDeployBlueGreenLifecycleEventHooks.builder()
                .afterAllowTestTraffic("afterAllowTestTraffic")
                .afterAllowTraffic("afterAllowTraffic")
                .afterInstall("afterInstall")
                .beforeAllowTraffic("beforeAllowTraffic")
                .beforeInstall("beforeInstall")
                .build())
        .trafficRoutingConfig(CfnTrafficRoutingConfig.builder()
                .type(CfnTrafficRoutingType.ALL_AT_ONCE)

                // the properties below are optional
                .timeBasedCanary(CfnTrafficRoutingTimeBasedCanary.builder()
                        .bakeTimeMins(123)
                        .stepPercentage(123)
                        .build())
                .timeBasedLinear(CfnTrafficRoutingTimeBasedLinear.builder()
                        .bakeTimeMins(123)
                        .stepPercentage(123)
                        .build())
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;

var cfnCodeDeployBlueGreenHookProps = new CfnCodeDeployBlueGreenHookProps {
    Applications = new [] { new CfnCodeDeployBlueGreenApplication {
        EcsAttributes = new CfnCodeDeployBlueGreenEcsAttributes {
            TaskDefinitions = new [] { "taskDefinitions" },
            TaskSets = new [] { "taskSets" },
            TrafficRouting = new CfnTrafficRouting {
                ProdTrafficRoute = new CfnTrafficRoute {
                    LogicalId = "logicalId",
                    Type = "type"
                },
                TargetGroups = new [] { "targetGroups" },
                TestTrafficRoute = new CfnTrafficRoute {
                    LogicalId = "logicalId",
                    Type = "type"
                }
            }
        },
        Target = new CfnCodeDeployBlueGreenApplicationTarget {
            LogicalId = "logicalId",
            Type = "type"
        }
    } },
    ServiceRole = "serviceRole",

    // the properties below are optional
    AdditionalOptions = new CfnCodeDeployBlueGreenAdditionalOptions {
        TerminationWaitTimeInMinutes = 123
    },
    LifecycleEventHooks = new CfnCodeDeployBlueGreenLifecycleEventHooks {
        AfterAllowTestTraffic = "afterAllowTestTraffic",
        AfterAllowTraffic = "afterAllowTraffic",
        AfterInstall = "afterInstall",
        BeforeAllowTraffic = "beforeAllowTraffic",
        BeforeInstall = "beforeInstall"
    },
    TrafficRoutingConfig = new CfnTrafficRoutingConfig {
        Type = CfnTrafficRoutingType.ALL_AT_ONCE,

        // the properties below are optional
        TimeBasedCanary = new CfnTrafficRoutingTimeBasedCanary {
            BakeTimeMins = 123,
            StepPercentage = 123
        },
        TimeBasedLinear = new CfnTrafficRoutingTimeBasedLinear {
            BakeTimeMins = 123,
            StepPercentage = 123
        }
    }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"

cfnCodeDeployBlueGreenHookProps := &CfnCodeDeployBlueGreenHookProps{
	Applications: []CfnCodeDeployBlueGreenApplication{
		&CfnCodeDeployBlueGreenApplication{
			EcsAttributes: &CfnCodeDeployBlueGreenEcsAttributes{
				TaskDefinitions: []*string{
					jsii.String("taskDefinitions"),
				},
				TaskSets: []*string{
					jsii.String("taskSets"),
				},
				TrafficRouting: &CfnTrafficRouting{
					ProdTrafficRoute: &CfnTrafficRoute{
						LogicalId: jsii.String("logicalId"),
						Type: jsii.String("type"),
					},
					TargetGroups: []*string{
						jsii.String("targetGroups"),
					},
					TestTrafficRoute: &CfnTrafficRoute{
						LogicalId: jsii.String("logicalId"),
						Type: jsii.String("type"),
					},
				},
			},
			Target: &CfnCodeDeployBlueGreenApplicationTarget{
				LogicalId: jsii.String("logicalId"),
				Type: jsii.String("type"),
			},
		},
	},
	ServiceRole: jsii.String("serviceRole"),

	// the properties below are optional
	AdditionalOptions: &CfnCodeDeployBlueGreenAdditionalOptions{
		TerminationWaitTimeInMinutes: jsii.Number(123),
	},
	LifecycleEventHooks: &CfnCodeDeployBlueGreenLifecycleEventHooks{
		AfterAllowTestTraffic: jsii.String("afterAllowTestTraffic"),
		AfterAllowTraffic: jsii.String("afterAllowTraffic"),
		AfterInstall: jsii.String("afterInstall"),
		BeforeAllowTraffic: jsii.String("beforeAllowTraffic"),
		BeforeInstall: jsii.String("beforeInstall"),
	},
	TrafficRoutingConfig: &CfnTrafficRoutingConfig{
		Type: cdk.CfnTrafficRoutingType_ALL_AT_ONCE,

		// the properties below are optional
		TimeBasedCanary: &CfnTrafficRoutingTimeBasedCanary{
			BakeTimeMins: jsii.Number(123),
			StepPercentage: jsii.Number(123),
		},
		TimeBasedLinear: &CfnTrafficRoutingTimeBasedLinear{
			BakeTimeMins: jsii.Number(123),
			StepPercentage: jsii.Number(123),
		},
	},
}
```

## 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)[] (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
