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

add possibility to cache specific ami version #389

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/aurora-serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class BastionHostAuroraServerlessForward extends BastionHostForward {
clientTimeout: props.clientTimeout,
serverTimeout: props.serverTimeout,
shouldPatch: props.shouldPatch,
cachedInContext: props.cachedInContext,
});

if (props.iamUser !== undefined && props.resourceIdentifier !== undefined) {
Expand Down
21 changes: 21 additions & 0 deletions lib/bastion-host-forward-base-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,25 @@ export interface BastionHostForwardBaseProps {
* @default true
*/
readonly shouldPatch?: boolean;

/**
* Whether the AMI ID is cached to be stable between deployments
*
* By default, the newest image is used on each deployment. This will cause
* instances to be replaced whenever a new version is released, and may cause
* downtime if there aren't enough running instances in the AutoScalingGroup
* to reschedule the tasks on.
*
* If set to true, the AMI ID will be cached in `cdk.context.json` and the
* same value will be used on future runs. Your instances will not be replaced
* but your AMI version will grow old over time. To refresh the AMI lookup,
* you will have to evict the value from the cache using the `cdk context`
* command. See https://docs.aws.amazon.com/cdk/latest/guide/context.html for
* more information.
*
* Can not be set to `true` in environment-agnostic stacks.
*
* @default false
*/
readonly cachedInContext?: boolean;
}
1 change: 1 addition & 0 deletions lib/bastion-host-forward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export class BastionHostForward extends Construct {
machineImage: new AmazonLinuxImage({
cpuType: AmazonLinuxCpuType.ARM_64,
generation: AmazonLinuxGeneration.AMAZON_LINUX_2023,
cachedInContext: props.cachedInContext,
}),
instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.NANO),
blockDevices: [
Expand Down
1 change: 1 addition & 0 deletions lib/generic-bastion-host-forward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class GenericBastionHostForward extends BastionHostForward {
clientTimeout: props.clientTimeout,
serverTimeout: props.serverTimeout,
shouldPatch: props.shouldPatch,
cachedInContext: props.cachedInContext,
});
}
}
1 change: 1 addition & 0 deletions lib/rds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class BastionHostRDSForward extends BastionHostForward {
clientTimeout: props.clientTimeout,
serverTimeout: props.serverTimeout,
shouldPatch: props.shouldPatch,
cachedInContext: props.cachedInContext,
});

if (props.iamUser !== undefined && props.rdsResourceIdentifier !== undefined) {
Expand Down