Skip to content

(aws-autoscaling): notificationTarget shouldn't be compulsory in LifecycleHook #14641

Closed
@abeer91

Description

@abeer91

The notificationTarget property can be unset and by default it will be able to use CWE to deliver Autoscaling Group notifications.

ASG API - https://docs.aws.amazon.com/cli/latest/reference/autoscaling/put-lifecycle-hook.html , keeps [--notification-target-arn <value>] as an optional param.

I was able to use L1 construct - CfnLifecycleHook as such without providing the notificationTarget

        const lcHook = new autoscaling.CfnLifecycleHook(this, "LCHook", {
            autoScalingGroupName: nodegroup.autoScalingGroupName,
            lifecycleTransition: LifecycleTransition.INSTANCE_TERMINATING,
            defaultResult: DefaultResult.CONTINUE,
            lifecycleHookName: "TerminateLifecycleHook",
            heartbeatTimeout: 300
        })

Reproduction Steps

Documentation shows property is mandatory - https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-autoscaling.LifecycleHook.html

What did you expect to happen?

notificationTarget should be optional or should have a way to use the default CWE integration.

What actually happened?

Could not use CWE integration which is how aws-node-termination-handler needs to be configured

Environment

  • CDK CLI Version : 1.97.0
  • Framework Version:
  • Node.js Version: v15.9.0
  • OS : Mac
  • Language (Version): TypeScript

Other


This is 🐛 Bug Report

Activity

added
bugThis issue is a bug.
needs-triageThis issue or PR still needs to be triaged.
on May 11, 2021
removed their assignment
on Jun 21, 2021
peterwoodworth

peterwoodworth commented on Jun 28, 2021

@peterwoodworth
Contributor

Sorry for the long reply here,

You're right. This isn't required from the Cfn side of things, so the L2 construct could have notificationTargets be an optional property. This seems to be the only place the property is used: lines 104 and 113

const targetProps = props.notificationTarget.bind(this, this);
const resource = new CfnLifecycleHook(this, 'Resource', {
autoScalingGroupName: props.autoScalingGroup.autoScalingGroupName,
defaultResult: props.defaultResult,
heartbeatTimeout: props.heartbeatTimeout && props.heartbeatTimeout.toSeconds(),
lifecycleHookName: this.physicalName,
lifecycleTransition: props.lifecycleTransition,
notificationMetadata: props.notificationMetadata,
notificationTargetArn: targetProps.notificationTargetArn,
roleArn: this.role.roleArn,
});

I'm not sure why this is required in the first place, but I can't find a reason for making it required

added
effort/smallSmall work item – less than a day of effort
good first issueRelated to contributions. See CONTRIBUTING.md
and removed
needs-triageThis issue or PR still needs to be triaged.
on Jun 28, 2021
self-assigned this
on Aug 23, 2021
added a commit that references this issue on Dec 11, 2021
4e7a275
github-actions

github-actions commented on Dec 11, 2021

@github-actions
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

added a commit that references this issue on Feb 21, 2022
d343fe1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-autoscalingRelated to Amazon EC2 Auto ScalingbugThis issue is a bug.effort/smallSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdp2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @NetaNir@abeer91@peterwoodworth@comcalvi

    Issue actions

      (aws-autoscaling): notificationTarget shouldn't be compulsory in LifecycleHook · Issue #14641 · aws/aws-cdk