Skip to main content

guard_hooks

Creates, updates, deletes or gets a guard_hook resource or lists guard_hooks in a region

Overview

Nameguard_hooks
TypeResource
DescriptionThis is a CloudFormation resource for activating the first-party AWS::Hooks::GuardHook.
Idawscc.cloudformation.guard_hooks

Fields

NameDatatypeDescription
rule_locationobjectS3 Source Location for the Guard files.
log_bucketstringS3 Bucket where the guard validate report will be uploaded to
hook_statusstringAttribute to specify which stacks this hook applies to or should get invoked for
target_operationsarrayWhich operations should this Hook run against? Resource changes, stacks or change sets.
failure_modestringAttribute to specify CloudFormation behavior on hook failure.
target_filtersobjectAttribute to specify which targets should invoke the hook
stack_filtersobjectFilters to allow hooks to target specific stack attributes
aliasstringThe typename alias for the hook.
hook_arnstringThe Amazon Resource Name (ARN) of the activated hook
execution_rolestringThe execution role ARN assumed by hooks to read Guard rules from S3 and write Guard outputs to S3.
optionsobject
regionstringAWS region.

For more information, see AWS::CloudFormation::GuardHook.

Methods

NameResourceAccessible byRequired Params
create_resourceguard_hooksINSERTRuleLocation, HookStatus, TargetOperations, FailureMode, Alias, ExecutionRole, region
delete_resourceguard_hooksDELETEIdentifier, region
update_resourceguard_hooksUPDATEIdentifier, PatchDocument, region
list_resourcesguard_hooks_list_onlySELECTregion
get_resourceguard_hooksSELECTIdentifier, region

SELECT examples

Gets all properties from an individual guard_hook.

SELECT
region,
rule_location,
log_bucket,
hook_status,
target_operations,
failure_mode,
target_filters,
stack_filters,
alias,
hook_arn,
execution_role,
options
FROM awscc.cloudformation.guard_hooks
WHERE
region = '{{ region }}' AND
Identifier = '{{ hook_arn }}';

INSERT example

Use the following StackQL query and manifest file to create a new guard_hook resource, using stack-deploy.

/*+ create */
INSERT INTO awscc.cloudformation.guard_hooks (
RuleLocation,
HookStatus,
TargetOperations,
FailureMode,
Alias,
ExecutionRole,
region
)
SELECT
'{{ rule_location }}',
'{{ hook_status }}',
'{{ target_operations }}',
'{{ failure_mode }}',
'{{ alias }}',
'{{ execution_role }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

UPDATE example

Use the following StackQL query and manifest file to update a guard_hook resource, using stack-deploy.

/*+ update */
UPDATE awscc.cloudformation.guard_hooks
SET PatchDocument = string('{{ {
"RuleLocation": rule_location,
"LogBucket": log_bucket,
"HookStatus": hook_status,
"TargetOperations": target_operations,
"FailureMode": failure_mode,
"TargetFilters": target_filters,
"StackFilters": stack_filters,
"Options": options
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ hook_arn }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

DELETE example

/*+ delete */
DELETE FROM awscc.cloudformation.guard_hooks
WHERE
Identifier = '{{ hook_arn }}' AND
region = '{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

Additional Parameters

Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:

ParameterDescription
ClientToken
A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.
A client token is valid for 36 hours once used.
After that, a resource request with the same client token is treated as a new request.
If you do not specify a client token, one is generated for inclusion in the request.
RoleArn
The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.
If you do not specify a role, a temporary session is created using your AWS user credentials.
TypeVersionId
For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used.

Permissions

To operate on the guard_hooks resource, the following permissions are required:

cloudformation:ActivateType,
cloudformation:DescribeType,
cloudformation:ListTypes,
cloudformation:SetTypeConfiguration,
cloudformation:BatchDescribeTypeConfigurations,
iam:PassRole