Skip to content

InstanceRefresh

Source: src/AWS/AutoScaling/InstanceRefresh.ts

Runtime binding for the instance refresh operations — StartInstanceRefresh, CancelInstanceRefresh, RollbackInstanceRefresh (IAM actions scoped to the group ARN) and DescribeInstanceRefreshes (granted on *; EC2 Auto Scaling Describe* actions do not support resource-level permissions).

Lets a deploy pipeline Lambda roll the fleet onto a new launch template version, watch progress, and cancel or roll back a bad deploy. Provide the implementation with Effect.provide(AWS.AutoScaling.InstanceRefreshHttp).

Roll the fleet and watch progress

// init — bind the operations to the group
const refresh = yield* AWS.AutoScaling.InstanceRefresh(group);
// runtime — start a rolling replacement with auto-rollback
const { InstanceRefreshId } = yield* refresh.start({
Preferences: { MinHealthyPercentage: 90, AutoRollback: true },
});
// runtime — check on it
const page = yield* refresh.describe({
InstanceRefreshIds: [InstanceRefreshId!],
});

Cancel a bad deploy

yield* refresh.cancel().pipe(
Effect.catchTag("ActiveInstanceRefreshNotFoundFault", () => Effect.void),
);