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

feat(ec2): support instanceInitiatedShutdownBehavior for EC2 instance #30160

Merged
merged 9 commits into from
May 27, 2024
11 changes: 10 additions & 1 deletion packages/aws-cdk-lib/aws-ec2/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Connections, IConnectable } from './connections';
import { CfnInstance } from './ec2.generated';
import { InstanceType } from './instance-types';
import { IKeyPair } from './key-pair';
import { CpuCredits } from './launch-template';
import { CpuCredits, InstanceInitiatedShutdownBehavior } from './launch-template';
import { IMachineImage, OperatingSystemType } from './machine-image';
import { instanceBlockDeviceMappings } from './private/ebs-util';
import { ISecurityGroup, SecurityGroup } from './security-group';
Expand Down Expand Up @@ -315,6 +315,14 @@ export interface InstanceProps {
* @default false
*/
readonly ebsOptimized?: boolean;

/**
* Indicates whether an instance stops or terminates when you initiate shutdown from the instance
* (using the operating system command for system shutdown).
*
badmintoncryer marked this conversation as resolved.
Show resolved Hide resolved
* @default InstanceInitiatedShutdownBehavior.STOP
badmintoncryer marked this conversation as resolved.
Show resolved Hide resolved
*/
readonly instanceInitiatedShutdownBehavior?: InstanceInitiatedShutdownBehavior;
}

/**
Expand Down Expand Up @@ -486,6 +494,7 @@ export class Instance extends Resource implements IInstance {
monitoring: props.detailedMonitoring,
creditSpecification: props.creditSpecification ? { cpuCredits: props.creditSpecification } : undefined,
ebsOptimized: props.ebsOptimized,
instanceInitiatedShutdownBehavior: props.instanceInitiatedShutdownBehavior,
});
this.instance.node.addDependency(this.role);

Expand Down
Loading