Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
abeer91 opened this issue May 11, 2021 · 2 comments · Fixed by #16187
Closed

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

abeer91 opened this issue May 11, 2021 · 2 comments · Fixed by #16187
Assignees
Labels
@aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p2

Comments

@abeer91
Copy link

abeer91 commented May 11, 2021

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

@abeer91 abeer91 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 11, 2021
@github-actions github-actions bot added the @aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling label May 11, 2021
@NetaNir NetaNir removed their assignment Jun 21, 2021
@peterwoodworth
Copy link
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

@peterwoodworth peterwoodworth added p2 effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md and removed needs-triage This issue or PR still needs to be triaged. labels Jun 28, 2021
@comcalvi comcalvi self-assigned this Aug 23, 2021
@mergify mergify bot closed this as completed in #16187 Dec 11, 2021
mergify bot pushed a commit that referenced this issue Dec 11, 2021
…ecycleHook (#16187)

This makes the notificationTargetArn optional in LifecycleHook. CloudFormation docs specify it as optional [here](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-as-lifecyclehook.html). Closes #14641. 
To achieve this, the `role` parameter was made optional. To avoid breaking users, a role is provided if users specify a `notificationTarget` (which they currently all do, as it is a required property) and is not provided otherwise.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️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.

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
…ecycleHook (aws#16187)

This makes the notificationTargetArn optional in LifecycleHook. CloudFormation docs specify it as optional [here](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-as-lifecyclehook.html). Closes aws#14641. 
To achieve this, the `role` parameter was made optional. To avoid breaking users, a role is provided if users specify a `notificationTarget` (which they currently all do, as it is a required property) and is not provided otherwise.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants