This message was deleted.
# aws
s
This message was deleted.
you can either add it inline to the
ingress
or
egress
array, or define a rule for each
j
Copy code
sg = aws.ec2.SecurityGroup("dev-sg",
    description = "Allow web traffic for cluster",
    vpc_id = vpc.vpc_id,
    ingress = [aws.ec2.SecurityGroupIngressArgs(
        description = "Allow port 80 inbound from Internet",
        from_port = 80,
        to_port = 80,
        protocol = "TCP",
        cidr_blocks = ["0.0.0.0/0"]
    ),
        description = "Allow port 3000 in from the SG",
        from_port = 3000,
        to_port = 3000,
        protocol = "TCP",
        self = True
    ],
    egress = [aws.ec2.SecurityGroupEgressArgs(
        description = "Allow all traffic out from cluster",
        from_port = 0,
        to_port = 0,
        protocol = "-1",
        cidr_blocks = ["0.0.0.0/0"],
        description = "Allow port 3000 out to the SG",
        from_port = 3000,
        to_prot = 3000,
        protocol = "TCP",
        self = True
    )]
)
I can't seem to get the inline to work
b
Copy code
sg = aws.ec2.SecurityGroup("dev-sg",
    description = "Allow web traffic for cluster",
    vpc_id = vpc.vpc_id,
    ingress = [aws.ec2.SecurityGroupIngressArgs(
        description = "Allow port 80 inbound from Internet",
        from_port = 80,
        to_port = 80,
        protocol = "TCP",
        cidr_blocks = ["0.0.0.0/0"]
    ),
        aws.ec2.SecurityGroupIngressArgs(
        description = "Allow port 3000 in from the SG",
        from_port = 3000,
        to_port = 3000,
        protocol = "TCP",
        self = True)
    ],
)
j
Thankyou I forgot the Args... Working now
Copy code
sg = aws.ec2.SecurityGroup("dev-sg",
    description = "Allow web traffic for cluster",
    vpc_id = vpc.vpc_id,
    ingress = [aws.ec2.SecurityGroupIngressArgs(
        description = "Allow port 80 inbound from Internet",
        from_port = 80,
        to_port = 80,
        protocol = "TCP",
        cidr_blocks = ["0.0.0.0/0"]
    ),
    aws.ec2.SecurityGroupIngressArgs(
        description = "Allow port 3000 in from the SG",
        from_port = 3000,
        to_port = 3000,
        protocol = "TCP",
        self = True
    )],
    egress = [aws.ec2.SecurityGroupEgressArgs(
        description = "Allow all traffic out from cluster",
        from_port = 0,
        to_port = 0,
        protocol = "-1",
        cidr_blocks = ["0.0.0.0/0"],
    ),
    aws.ec2.SecurityGroupIngressArgs(
        description = "Allow port 3000 out to the SG",
        from_port = 3000,
        to_port = 3000,
        protocol = "TCP",
        self = True
    )]
)