[英]Creating ServerDeploymentGroup in AWS-CDK that deploys to autoscalling group using codedeploy
我正在嘗試使用 aws-cdk(Java 語言)創建 AWS 管道。階段如下: 來源:Codecommit 構建:Codebuild 部署:使用 CodeDeploy 部署到 Autoscaling 組
我正在努力使用 aws cdk 創建 ServerDeploymentGroup。 我已經創建了要在 ServerDeploymentGroup 中使用的 Autoscaling 組。 但無法在 AWS-CDK 中進行配置。 獲取 ClassCastException:
這是我的代碼,用於創建 AutoscalingGroup 和 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 中解決這個問題?
AWS CDK 代碼中存在錯誤,因為 ServerDeploymentGroup 接受 AutoscalingGroup 列表而不是 IAutoScalingGroup 列表。 該錯誤已在 8 月 12 日的v1.58.0版本中修復。 現在我能夠解決我上面提到的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.