Skip to content

Commit

Permalink
add possibility to cache specific ami version (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
snowiow authored Feb 5, 2024
1 parent 0cf3b76 commit 67b58f3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
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

0 comments on commit 67b58f3

Please sign in to comment.