Skip to content
GitHubXDiscord

HookDefaultVersion

The HookDefaultVersion resource allows you to manage the default version of a CloudFormation hook, which can be used for custom resource types. This resource enables you to specify the hook’s type name, version ID, and ARN. For more detailed information, visit the AWS CloudFormation HookDefaultVersions documentation.

Create a basic HookDefaultVersion with the required properties and one optional property.

import AWS from "alchemy/aws/control";
const hookDefaultVersion = await AWS.CloudFormation.HookDefaultVersion("MyHookDefaultVersion", {
TypeName: "MyCustomHook",
VersionId: "v1.0.0"
});

Here’s an example that includes additional optional properties like TypeVersionArn and adopt.

const advancedHookDefaultVersion = await AWS.CloudFormation.HookDefaultVersion("AdvancedHookDefaultVersion", {
TypeName: "MyAdvancedCustomHook",
VersionId: "v2.0.0",
TypeVersionArn: "arn:aws:cloudformation:us-west-2:123456789012:type/MyAdvancedCustomHook/v2.0.0",
adopt: true // Adopt existing resource if it already exists
});

This example shows how to adopt an existing hook default version instead of failing when it already exists.

const adoptHookDefaultVersion = await AWS.CloudFormation.HookDefaultVersion("AdoptExistingHook", {
TypeName: "MyExistingCustomHook",
VersionId: "v1.0.0",
adopt: true // Set to true to adopt the existing resource
});

In this example, we set up a complete hook configuration with all relevant properties.

const completeHookDefaultVersion = await AWS.CloudFormation.HookDefaultVersion("CompleteHook", {
TypeName: "MyCompleteCustomHook",
VersionId: "v1.0.0",
TypeVersionArn: "arn:aws:cloudformation:us-west-2:123456789012:type/MyCompleteCustomHook/v1.0.0",
adopt: false // Set to false to fail if the resource exists
});