希望有人可以在这里帮助我,根据 AWS CDK 文档,如果我声明我的 VPC,那么我不应该声明 'capacity',但是当我运行cdk synth时出现以下错误......
抛出新的错误(
Validation failed with the following errors:\n ${errorList}
);错误:验证失败并出现以下错误:[PrerenderInfrasctutureStack/preRenderApp/Service] 此服务的集群需要 Ec2 容量。在集群上调用 addXxxCapacity()。
这是我的代码......(我希望 Nathan Peck 看到这个)
const ec2 = require('@aws-cdk/aws-ec2');
const ecsPattern = require('@aws-cdk/aws-ecs-patterns');
const ecs = require('@aws-cdk/aws-ecs');
class PrerenderInfrasctutureStack extends cdk.Stack {
/**
*
* @param {cdk.Construct} scope
* @param {string} id
* @param {cdk.StackProps=} props
*/
constructor(scope, id, props) {
super(scope, id, props);
const myVPC = ec2.Vpc.fromLookup(this, 'publicVpc', {
vpcId:'vpc-xxx'
});
const preRenderApp = new ecsPattern.ApplicationLoadBalancedEc2Service(this, 'preRenderApp', {
vpcId: myVPC,
certificate: 'arn:aws:acm:ap-southeast-2:xxx:certificate/xxx', //becuase this is spcified, then the LB will automatically use HTTPS
domainName: 'my-dev.com.au.',
domainZone:'my-dev.com.au',
listenerPort: 443,
publicLoadBalancer: true,
memoryReservationMiB: 8,
cpu: 4096,
desiredCount: 1,
taskImageOptions:{
image: ecs.ContainerImage.fromRegistry('xxx.dkr.ecr.region.amazonaws.com/express-prerender-server'),
containerPort: 3000
},
});
}
}
module.exports = { PrerenderInfrasctutureStack }