有没有办法在自动缩放计划中指定时区?
Is there a way to specify timezone in an auto-scaling schedule?
我正在使用 CDK 按计划自动缩放 Lambda 预配置的并发。例如:
// Define the provisioned concurrency
const target = new asg.ScalableTarget(this, 'ScalableTarget', {
serviceNamespace: asg.ServiceNamespace.LAMBDA,
maxCapacity: 1,
minCapacity: 0,
resourceId: `function:${alias.lambda.functionName}:${alias.aliasName}`,
scalableDimension: 'lambda:function:ProvisionedConcurrency'
});
target.node.addDependency(alias);
// Start the provisioned concurrency at 8am
target.scaleOnSchedule('ScaleUpInTheMorning', {
schedule: asg.Schedule.cron({ hour: '08', minute: '00' }),
minCapacity: 1,
maxCapacity: 1
});
// Stop the provisioned concurrency at night
target.scaleOnSchedule('ScaleDownAtNight', {
schedule: asg.Schedule.cron({ hour: '17', minute: '10' }),
minCapacity: 0
maxCapacity: 0
});
根据我的阅读和我自己的测试,cron 定义中的时间是 UTC。
有没有办法指定时区?
您可以使用 L1 构造实现此目的,因为 CloudFormation 支持它:
https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-applicationautoscaling.CfnScalableTarget.html
我对 TypeScript 没有任何经验,所以希望以下语法是正确的。无论如何,你明白了。
const target = new asg.CfnScalableTarget(this, 'ScalableTarget', {
serviceNamespace: asg.ServiceNamespace.LAMBDA,
maxCapacity: 1,
minCapacity: 0,
resourceId: `function:${alias.lambda.functionName}:${alias.aliasName}`,
scalableDimension: 'lambda:function:ProvisionedConcurrency',
scheduledActions: {
schedule: asg.Schedule.cron(
{ hour: '08', minute: '00' }).expressionString,
scheduledActionName: 'morning',
timezone: 'Pacific/Tahiti'
},
scalableTargetAction: {
minCapacity: 1,
maxCapacity: 1
}
});
我正在使用 CDK 按计划自动缩放 Lambda 预配置的并发。例如:
// Define the provisioned concurrency
const target = new asg.ScalableTarget(this, 'ScalableTarget', {
serviceNamespace: asg.ServiceNamespace.LAMBDA,
maxCapacity: 1,
minCapacity: 0,
resourceId: `function:${alias.lambda.functionName}:${alias.aliasName}`,
scalableDimension: 'lambda:function:ProvisionedConcurrency'
});
target.node.addDependency(alias);
// Start the provisioned concurrency at 8am
target.scaleOnSchedule('ScaleUpInTheMorning', {
schedule: asg.Schedule.cron({ hour: '08', minute: '00' }),
minCapacity: 1,
maxCapacity: 1
});
// Stop the provisioned concurrency at night
target.scaleOnSchedule('ScaleDownAtNight', {
schedule: asg.Schedule.cron({ hour: '17', minute: '10' }),
minCapacity: 0
maxCapacity: 0
});
根据我的阅读和我自己的测试,cron 定义中的时间是 UTC。
有没有办法指定时区?
您可以使用 L1 构造实现此目的,因为 CloudFormation 支持它: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-applicationautoscaling.CfnScalableTarget.html
我对 TypeScript 没有任何经验,所以希望以下语法是正确的。无论如何,你明白了。
const target = new asg.CfnScalableTarget(this, 'ScalableTarget', {
serviceNamespace: asg.ServiceNamespace.LAMBDA,
maxCapacity: 1,
minCapacity: 0,
resourceId: `function:${alias.lambda.functionName}:${alias.aliasName}`,
scalableDimension: 'lambda:function:ProvisionedConcurrency',
scheduledActions: {
schedule: asg.Schedule.cron(
{ hour: '08', minute: '00' }).expressionString,
scheduledActionName: 'morning',
timezone: 'Pacific/Tahiti'
},
scalableTargetAction: {
minCapacity: 1,
maxCapacity: 1
}
});