Last active
October 13, 2021 15:23
-
-
Save ankyit/4dd4e4624cf9473c5f16f0e3e776e895 to your computer and use it in GitHub Desktop.
alicloud-pulumi-python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pulumi import export | |
import pulumi_alicloud as alicloud | |
vpc = alicloud.vpc.Network( "web_dev_vpc", | |
vpc_name="alicloud_webdev_vpc", | |
description="Webdev VPC created with Pulumi", | |
cidr_block="192.168.0.0/16", | |
tags={ | |
"created-with":"pulumi", | |
"created-by":"ankit", | |
"environment":"dev", | |
} | |
) | |
webservervSwitch = alicloud.vpc.Switch( "web_server_vSwitch", | |
vswitch_name="webServer", | |
cidr_block="192.168.1.0/24", | |
vpc_id=vpc.id, | |
zone_id="ap-southeast-1a", | |
tags={ | |
"created-with":"pulumi", | |
"created-by":"ankit", | |
"environment":"dev", | |
} | |
) | |
databaseservervSwitch = alicloud.vpc.Switch( "database_server_vSwitch", | |
vswitch_name="dbServer", | |
cidr_block="192.168.2.0/24", | |
vpc_id=vpc.id, | |
zone_id="ap-southeast-1b", | |
tags={ | |
"created-with":"pulumi", | |
"created-by":"ankit", | |
"environment":"dev", | |
} | |
) | |
WebserverSG = alicloud.ecs.SecurityGroup("WebServerSG", | |
name="webserver-sg", | |
vpc_id=vpc.id, | |
tags={ | |
"created-with":"pulumi", | |
"created-by":"ankit", | |
"environment":"dev", | |
} | |
) | |
DBserverSG = alicloud.ecs.SecurityGroup("DBServerSG", | |
name="dbServer-sg", | |
vpc_id=vpc.id, | |
tags={ | |
"created-with":"pulumi", | |
"created-by":"ankit", | |
"environment":"dev", | |
} | |
) | |
alicloud.ecs.SecurityGroupRule("WebServer-HTTP-SGR", | |
ip_protocol="tcp", | |
security_group_id=WebserverSG.id, | |
type="ingress", | |
policy="accept", | |
port_range="80/80", | |
cidr_ip="0.0.0.0/0" | |
) | |
alicloud.ecs.SecurityGroupRule("WebServer-HTTPS-SGR", | |
ip_protocol="tcp", | |
security_group_id=WebserverSG.id, | |
type="ingress", | |
policy="accept", | |
port_range="443/443", | |
cidr_ip="0.0.0.0/0" | |
) | |
alicloud.ecs.SecurityGroupRule("DB-SGR", | |
ip_protocol="tcp", | |
security_group_id=DBserverSG.id, | |
type="ingress", | |
policy="accept", | |
port_range="3306/3306", | |
cidr_ip=webservervSwitch.cidr_block | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment