我想知道如何导入另一个堆栈中定义的安全组,然后在当前堆栈中使用。
到目前为止我已经尝试过这个..
class relayStack extends cdk.Stack {
public sg_relay: ec2.SecurityGroupRefProps
constructor(parent: cdk.App, name: string, props: VPCProps) {
super(parent, name, props);
//#IMPORT VPC PROPS
const vpc = ec2.VpcNetwork.import(this, 'VPC-Hottest100', props.infra.vpc);
//#AUTOSCALING GROUP
const asg_relayServer = new ec2.AutoScalingGroup(this, 'ASG_Relay', {
vpc,
instanceType: new ec2.InstanceTypePair(ec2.InstanceClass.T2, ec2.InstanceSize.Small),
minSize: 1,
maxSize: 3,
desiredCapacity: 1,
machineImage: new ec2.GenericLinuxImage({
"ap-southeast-2": "ami-dc361ebf",
}),
keyName: 'icecast-poc',
allowAllOutbound: false,
vpcPlacement: {
usePublicSubnets: false
}
});
//#SECURITY Group
const sg_relay = new ec2.SecurityGroup(this, 'SG_RELAY', {
vpc,
description: "Relay stack security group", …Run Code Online (Sandbox Code Playgroud) aws-cdk ×1