You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CDK Java version 0.9.2
As not many samples, creating a Launch configuration with 2 Security Groups, get the following error on cdk sythn cdk-sms104-NLB. When comment out the line it goes away, but don't have the security groups assigned.
Exception in thread "main" software.amazon.jsii.JsiiException: While synthesizing cdk-sms104-NLB/LaunchConfiguration: Trying to resolve() a Construct at /securityGroups/0
While synthesizing cdk-sms104-NLB/LaunchConfiguration: Trying to resolve() a Construct at /securityGroups/0
--- resource created at ---
Here is the code:
SecurityGroupIngressResource securityGroupIngressResourcePort80 = new SecurityGroupIngressResource(this,
"Port80Ingress", SecurityGroupIngressResourceProps.builder()
.withIpProtocol("tcp")
.withFromPort(80)
.withToPort(80)
.withCidrIp(new FnSub("10.${ProjectID}.0.0/22")) //TODO put into Fn:Sub //
// #TODO Secure this to only the .3 and .2 private network only
.build());
SecurityGroupResource securityGroupResource80 = new SecurityGroupResource(this, "Port80SecurityGroup",
SecurityGroupResourceProps.builder()
.withGroupDescription("Port80")
.withVpcId(new FnSub("SMS-${ProjectID}-VPC-VPCID"))
.withSecurityGroupIngress(Collections.singletonList(securityGroupIngressResourcePort80.getSecurityGroupIngressId()))
.build());
SecurityGroupIngressResource securityGroupIngressResourcePort22 = new SecurityGroupIngressResource(this,
"Port22Ingress", SecurityGroupIngressResourceProps.builder()
.withIpProtocol("tcp")
.withFromPort(22)
.withToPort(22)
.withCidrIp(new FnSub("10.${ProjectID}.0.0/22"))
.build()); //FUTURE: Add tags ?
SecurityGroupResource securityGroupResource22 = new SecurityGroupResource(this, "Port22SecurityGroup",
SecurityGroupResourceProps.builder()
.withGroupDescription("Port22")
.withVpcId(new FnSub("SMS-${ProjectID}-VPC-VPCID"))
.withSecurityGroupIngress(Collections.singletonList(securityGroupIngressResourcePort22.getSecurityGroupIngressId()))
.build());
List<Object> securityGroupList = new ArrayList(){{
add(securityGroupResource80);
add(securityGroupResource22);
}};
LaunchConfigurationResource launchConfigurationResource = new LaunchConfigurationResource(this, "LaunchConfiguration",
LaunchConfigurationResourceProps.builder()
.withLaunchConfigurationName(new FnSub("SMS-${ProjectID}-LaunchConfiguration"))
.withImageId(amiIDParam.getValue().toString())
.withKeyName(keyNameParam.getValue().toString())
.withSecurityGroups(securityGroupList) //TODO ERRORS
.withInstanceType(instanceTypeParam.getValue().toString())
.withAssociatePublicIpAddress(false)
.build());
-Yaakov
The text was updated successfully, but these errors were encountered:
The error is due to the fact that the SecurityGroups property of LaunchConfiguration is expected to be a list of security group IDs and securityGroupList contains objects instead of strings. To fix this, use this:
On a side note, I was wondering why you chose to use the low-level cloudformation resources instead of the high-level constructs in the @aws-cdk/autoscaling library? One of the main benefits of using the higher level library is that the APIs are richer and strong-typed, so you won't have issues such as this.
If you find missing features in this library, we would love to know about it. We are also working on a nicer way to "escape hatch" (#606) from the higher-level libraries for specific cases where you have gaps that you need to work around. Would love your feedback!
@eladb , As this is first experience with CDK, do not know what is the difference between high level and low level. Perhaps an example of the difference in Java would assist me in this understangin.
Issue resolved, thanks
CDK Java version 0.9.2
As not many samples, creating a Launch configuration with 2 Security Groups, get the following error on cdk sythn cdk-sms104-NLB. When comment out the line it goes away, but don't have the security groups assigned.
Exception in thread "main" software.amazon.jsii.JsiiException: While synthesizing cdk-sms104-NLB/LaunchConfiguration: Trying to resolve() a Construct at /securityGroups/0
While synthesizing cdk-sms104-NLB/LaunchConfiguration: Trying to resolve() a Construct at /securityGroups/0
--- resource created at ---
Here is the code:
-Yaakov
The text was updated successfully, but these errors were encountered: