1

我正在尝试使用 aws-cdk 将以下堆栈部署到 AWS:

/* imports omitted */

export class AwsEcsStack extends cdk.Stack {
    constructor(app: cdk.App, id: string) {
        super(app, id);

        const vpc = new ec2.Vpc(this, 'main', { maxAzs: 2 });

        const cluster = new ecs.Cluster(this, 'candy-workers', { vpc });
        cluster.addCapacity('candy-workers-asg', {
            instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.MICRO),
            associatePublicIpAddress: false
        });

        const logging = new ecs.AwsLogDriver({ streamPrefix: "candy-logs", logRetention: logs.RetentionDays.ONE_DAY })

        const repository = new ecr.Repository(this, 'candy-builds');
        repository.addLifecycleRule({ tagPrefixList: ['prod'], maxImageCount: 100 });
        repository.addLifecycleRule({ maxImageAge: cdk.Duration.days(30) });

        const taskDef = new ecs.Ec2TaskDefinition(this, "candy-task");
        taskDef.addContainer("candy-container", {
            image: ecs.ContainerImage.fromEcrRepository(repository),
            memoryLimitMiB: 512,
            logging
        })

        new ecs.Ec2Service(this, "candy-service", {
            cluster,
            taskDefinition: taskDef,
        });

        const candyTopic1 = new sns.Topic(this, 'candy1', {
            topicName: 'candy1',
            displayName: 'Produce some candy'
        })

        new sns.Topic(this, 'candy2', {
            topicName: 'candy2',
            displayName: 'Produce some more candy'
        })

        new sns.Topic(this, 'candy3', {
            topicName: 'candy3',
            displayName: 'Produce some more candy'
        })

        const rule = new events.Rule(this, 'candy-cron', {
            schedule: events.Schedule.expression('cron(0 * * ? * *)')
          });

        rule.addTarget(new targets.SnsTopic(candyTopic1));
    }
}

const app = new cdk.App();

new AwsEcsStack(app, 'candy-app');

app.synth();

但它在执行 53 中的第 50 步时失败:

 50/53 | 3:01:28 PM | CREATE_COMPLETE      | AWS::Lambda::Permission               | candy-workers/candy-workers-asg/DrainECSHook/Function/AllowInvoke:candyappcandyworkerscandyworkersasgLifecycleHookDrainHookTopic4AA69F1A (candyworkerscandyworkersasgDrainECSHookFunctionAllowInvokecandyappcandyworkerscandyworkersasgLifecycleHookDrainHookTopic4AA69F1AAFA44A3D)
50/53 Currently in progress: candyworkerscandyworkersasgLifecycleHookDrainHookRole4BCB2138, candyserviceServiceBB6CC91A

有时它也会挂在下一步:

 51/53 | 4:03:14 PM | CREATE_COMPLETE      | AWS::Lambda::Permission               | arbitrage-workers/arbitrage-workers-asg/DrainECSHook/Function/AllowInvoke:arbitrageapparbitrageworkersarbitrageworkersasgLifecycleHookDrainHookTopic4AA69F1A (arbitrageworkersarbitrageworkersasgDrainECSHookFunctionAllowInvokearbitrageapparbitrageworkersarbitrageworkersasgLifecycleHookDrainHookTopic4AA69F1AAFA44A3D)
51/53 Currently in progress: arbitrageserviceServiceBB6CC91A

我已经等了很长时间了,它还没有完成部署。我只能想象出了什么问题。

你有过这样的经历吗?

4

0 回答 0