我正在尝试使用aws-cdk(Java语言)创建一个AWS管道,其阶段如下: 资料来源:Codecommit 构建:代码构建 部署:使用CodeDeploy部署到Autoscalling组
我正在努力使用aws cdk创建ServerDeploymentGroup。我已经创建了要在ServerDeploymentGroup中使用的Autoscalling组。但是无法在AWS-CDK中进行配置。正在获取ClassCastException:
这是我的代码,用于创建AutoscallingGroup和ServerDeploymentGroup。
AutoScalingGroup autoScalingGroup = (AutoScalingGroup) AutoScalingGroup.fromAutoScalingGroupName(this, "autoscallinggroup", "myautscallinggroup");
List<AutoScalingGroup> autoScalingGroupList = new ArrayList<AutoScalingGroup>();
autoScalingGroupList.add(autoScalingGroup);
ServerDeploymentConfig deploymentConfig = (ServerDeploymentConfig) ServerDeploymentConfig.ALL_AT_ONCE;
ServerApplication application = ServerApplication.Builder.create(this, "codedeployapplication")
.applicationName("mydeployapplication")
.build();
ServerDeploymentGroup deploymentGroup = ServerDeploymentGroup.Builder.create(this, "codedeploymentgroup")
.application(application)
.autoScalingGroups(autoScalingGroupList)
.deploymentGroupName("MyDeploymentGroup")
.deploymentConfig(deploymentConfig)
.installAgent(true)
.role(codeDeployRole)
.build();
这是我得到的例外:
java.lang.ClassCastException: class software.amazon.awscdk.services.autoscaling.IAutoScalingGroup$Jsii$Proxy cannot be cast to class software.amazon.awscdk.services.autoscaling.AutoScalingGroup (software.amazon.awscdk.services.autoscaling.IAutoScalingGroup$Jsii$Proxy and software.amazon.awscdk.services.autoscaling.AutoScalingGroup are in unnamed module of loader 'app')
对此有任何帮助吗?如何在aws-cdk中解决此问题?
答案 0 :(得分:0)
AWS CDK代码中存在一个错误,原因是ServerDeploymentGroup接受AutoscalingGroup列表而不是IAutoScalingGroup列表。该错误已在8月12日发布的 v1.58.0 中修复。 现在我可以解决上述问题。