From 80acf2985ac1d543c7f93b12ce344debf375669f Mon Sep 17 00:00:00 2001 From: namse Date: Sun, 3 Dec 2023 09:47:27 +0000 Subject: [PATCH] No verifyInstanceHealth --- oioi/cdk/lib/index.ts | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/oioi/cdk/lib/index.ts b/oioi/cdk/lib/index.ts index d319e3e0d..38ac816d5 100644 --- a/oioi/cdk/lib/index.ts +++ b/oioi/cdk/lib/index.ts @@ -77,7 +77,7 @@ export class Oioi extends Construct { }, ); - const configs: Record = { + const initConfigs: Record = { setEnv: new cdk.aws_ec2.InitConfig([ cdk.aws_ec2.InitCommand.shellCommand("ec2-metadata -i"), cdk.aws_ec2.InitCommand.shellCommand( @@ -174,24 +174,8 @@ docker login --username AWS --password-stdin public.ecr.aws )} public.ecr.aws/o4b6l4b3/oioi:latest ./oioi-agent`, ), ]), - verifyInstanceHealth: new cdk.aws_ec2.InitConfig([ - cdk.aws_ec2.InitCommand.shellCommand( - ` -until [ "$state" == "\\"InService\\"" ]; do state=$(aws --region ${stack.region} elb describe-target-health ---load-balancer-name ${alb.loadBalancerName} ---instances $(ec2-metadata -i | cut -d ' ' -f 2) ---query InstanceStates[0].State); sleep 10; done`.replaceAll("\n", " "), - ), - ]), }; - const init = cdk.aws_ec2.CloudFormationInit.fromConfigSets({ - configSets: { - default: Object.keys(configs), - }, - configs, - }); - const autoScalingGroup = (this.autoScalingGroup = new cdk.aws_autoscaling.AutoScalingGroup(this, "ASG", { vpc, @@ -225,16 +209,6 @@ until [ "$state" == "\\"InService\\"" ]; do state=$(aws --region ${stack.region} ), ], inlinePolicies: { - cloudFormationHelper: new cdk.aws_iam.PolicyDocument({ - statements: [ - new cdk.aws_iam.PolicyStatement({ - actions: ["cloudformation:SignalResource"], - resources: [ - `arn:aws:cloudformation:${stack.region}:${stack.account}:stack/${stack.stackName}/*`, - ], - }), - ], - }), ecr: new cdk.aws_iam.PolicyDocument({ statements: [ new cdk.aws_iam.PolicyStatement({ @@ -252,11 +226,14 @@ until [ "$state" == "\\"InService\\"" ]; do state=$(aws --region ${stack.region} }), }, }), + init: cdk.aws_ec2.CloudFormationInit.fromConfigSets({ + configSets: { + default: Object.keys(initConfigs), + }, + configs: initConfigs, + }), })); - // `applyCloudFormationInit` for verbose logs - autoScalingGroup.applyCloudFormationInit(init); - autoScalingGroup.node.addDependency( systemMessagesLogGroup, agentLogGroup,