コード例 #1
0
ファイル: elasticip.py プロジェクト: ascential/pulpy
    def __init__(self):

        resource_specs = ParseYAML(resource_type).getSpecs()

        for eip_name, eip_configuration in resource_specs.items():

            # AWS Elastic IP Dynamic Variables
            resource_name = eip_name
            resource_tags = eip_configuration["tags"] if "'tags':" in str(
                eip_configuration) else None

            # Lists
            tags_list = {}

            # Getting list of tags from configuration file
            if resource_tags is not None:
                for each_tag_name, each_tag_value in resource_tags.items():
                    tags_list.update({each_tag_name: each_tag_value})

            # Adding mandatory tags
            tags_list.update({"Name": resource_name})
            tags_list.update({
                "Project/Stack":
                pulumi.get_project() + "/" + pulumi.get_stack()
            })
            tags_list.update(resource_mandatory_tags)

            eip = net.Eip(resource_name, tags=tags_list)

            eip_ids_dict.update({eip._name: eip.id})

            # Exporting each EIP
            pulumi.export(eip._name, eip.id)
コード例 #2
0
 def _create_private_subnet_route_table(self, public_subnet_id, vpcid):
     eip_name = "%s-nat-eip" % self.name
     nat_name = "%s-nat" % self.name
     eip = ec2.Eip(eip_name, __opts__=ResourceOptions(parent=self))
     nat_gateway = ec2.NatGateway(nat_name,
                                  subnet_id=public_subnet_id,
                                  allocation_id=eip.id,
                                  tags=self.vpc_tags,
                                  __opts__=ResourceOptions(parent=self))
     rt_name = "%s-private-rt" % self.name
     private_route_table = ec2.RouteTable(
         rt_name,
         vpc_id=vpcid,
         routes=[{
             "cidrBlock": "0.0.0.0/0",
             "gatewayId": nat_gateway.id
         }],
         __opts__=ResourceOptions(parent=self))
     return private_route_table.id
コード例 #3
0
ファイル: vpc.py プロジェクト: jaxxstorm/jen20-pulumi-aws-vpc
    def __init__(self,
                 name: str,
                 args: VpcArgs,
                 opts: pulumi.ResourceOptions = None):
        """
        Constructs a Vpc.

        :param name: The Pulumi resource name. Child resource names are constructed based on this.
        :param args: A VpcArgs object containing the arguments for VPC constructin.
        :param opts: A pulumi.ResourceOptions object.
        """
        super().__init__('Vpc', name, None, opts)

        # Make base info available to other methods
        self.name = name
        self.description = args.description
        self.base_tags = args.base_tags

        # Create VPC and Internet Gateway resources
        self.vpc = ec2.Vpc(f"{name}-vpc",
                           cidr_block=args.base_cidr,
                           enable_dns_hostnames=True,
                           enable_dns_support=True,
                           tags={
                               **args.base_tags, "Name":
                               f"{args.description} VPC"
                           },
                           opts=pulumi.ResourceOptions(parent=self, ))

        self.internet_gateway = ec2.InternetGateway(
            f"{name}-igw",
            vpc_id=self.vpc.id,
            tags={
                **args.base_tags, "Name":
                f"{args.description} VPC Internet Gateway"
            },
            opts=pulumi.ResourceOptions(parent=self.vpc, ))

        # Calculate subnet CIDR blocks and create subnets
        subnet_distributor = SubnetDistributor(
            args.base_cidr, len(args.availability_zone_names))

        self.public_subnets = [
            ec2.Subnet(f"{name}-public-subnet-{i}",
                       vpc_id=self.vpc.id,
                       cidr_block=cidr,
                       availability_zone=args.availability_zone_names[i],
                       map_public_ip_on_launch=True,
                       tags={
                           **args.base_tags, "Name":
                           f"${args.description} Public Subnet {i}"
                       },
                       opts=pulumi.ResourceOptions(parent=self.vpc, ))
            for i, cidr in enumerate(subnet_distributor.public_subnets)
        ]

        self.private_subnets = [
            ec2.Subnet(f"{name}-private-subnet-{i}",
                       vpc_id=self.vpc.id,
                       cidr_block=cidr,
                       availability_zone=args.availability_zone_names[i],
                       tags={
                           **args.base_tags, "Name":
                           f"${args.description} Private Subnet {i}"
                       },
                       opts=pulumi.ResourceOptions(parent=self.vpc, ))
            for i, cidr in enumerate(subnet_distributor.private_subnets)
        ]

        # Adopt the default route table for this VPC and adapt it for use with public subnets
        self.public_route_table = ec2.DefaultRouteTable(
            f"{name}-public-rt",
            default_route_table_id=self.vpc.default_route_table_id,
            tags={
                **args.base_tags, "Name":
                f"${args.description} Public Route Table"
            },
            opts=pulumi.ResourceOptions(parent=self.vpc, ))

        ec2.Route(f"{name}-route-public-sn-to-ig",
                  route_table_id=self.public_route_table.id,
                  destination_cidr_block="0.0.0.0/0",
                  gateway_id=self.internet_gateway.id,
                  opts=pulumi.ResourceOptions(parent=self.public_route_table))

        for i, subnet in enumerate(self.public_subnets):
            ec2.RouteTableAssociation(
                f"{name}-public-rta-{i + 1}",
                subnet_id=subnet.id,
                route_table_id=self.public_route_table,
                opts=pulumi.ResourceOptions(parent=self.public_route_table))

        self.nat_elastic_ip_addresses: [ec2.Eip] = list()
        self.nat_gateways: [ec2.NatGateway] = list()
        self.private_route_tables: [ec2.RouteTable] = list()

        # Create a NAT Gateway and appropriate route table for each private subnet
        for i, subnet in enumerate(self.private_subnets):
            self.nat_elastic_ip_addresses.append(
                ec2.Eip(f"{name}-nat-{i + 1}",
                        tags={
                            **args.base_tags, "Name":
                            f"{args.description} NAT Gateway EIP {i + 1}"
                        },
                        opts=pulumi.ResourceOptions(parent=subnet)))

            self.nat_gateways.append(
                ec2.NatGateway(
                    f"{name}-nat-gateway-{i + 1}",
                    allocation_id=self.nat_elastic_ip_addresses[i].id,
                    subnet_id=self.public_subnets[i].id,
                    tags={
                        **args.base_tags, "Name":
                        f"{args.description} NAT Gateway {i + 1}"
                    },
                    opts=pulumi.ResourceOptions(parent=subnet)))

            self.private_route_tables.append(
                ec2.RouteTable(f"{name}-private-rt-{i + 1}",
                               vpc_id=self.vpc.id,
                               tags={
                                   **args.base_tags, "Name":
                                   f"{args.description} Private RT {i + 1}"
                               },
                               opts=pulumi.ResourceOptions(parent=subnet)))

            ec2.Route(f"{name}-route-private-sn-to-nat-{i + 1}",
                      route_table_id=self.private_route_tables[i].id,
                      destination_cidr_block="0.0.0.0/0",
                      nat_gateway_id=self.nat_gateways[i].id,
                      opts=pulumi.ResourceOptions(
                          parent=self.private_route_tables[i]))

            ec2.RouteTableAssociation(
                f"{name}-private-rta-{i + 1}",
                subnet_id=subnet.id,
                route_table_id=self.private_route_tables[i].id,
                opts=pulumi.ResourceOptions(
                    parent=self.private_route_tables[i]))

        # Create S3 endpoint if necessary
        if args.create_s3_endpoint:
            ec2.VpcEndpoint(f"{name}-s3-endpoint",
                            vpc_id=self.vpc.id,
                            service_name=f"com.amazonaws.{config.region}.s3",
                            route_table_ids=[
                                self.public_route_table.id,
                                *[rt.id for rt in self.private_route_tables]
                            ],
                            opts=pulumi.ResourceOptions(parent=self.vpc))

        # Create DynamoDB endpoint if necessary
        if args.create_dynamodb_endpoint:
            ec2.VpcEndpoint(
                f"{name}-dynamodb-endpoint",
                vpc_id=self.vpc.id,
                service_name=f"com.amazonaws.{config.region}.dynamodb",
                route_table_ids=[
                    self.public_route_table.id,
                    *[rt.id for rt in self.private_route_tables]
                ],
                opts=pulumi.ResourceOptions(parent=self.vpc))

        super().register_outputs({})
コード例 #4
0
    # TODO `Quiver`: `Pulumi > Questions > Adding tags forces EC2 replacement?`
    #   edit: I also changed the instance's `resource_name`
    tags={
        'Name': 'infra public ec2 2 (front-back-autoscaling)',
        'Creator': 'timc'
    })

# TODO bug? If you include `associate_with_private_ip = server.private_ip` but
# leave off `instance = server.id`, the association is not created

# TODO move this to ALB when the time comes
eip_1 = ec2.Eip(resource_name='new-eip-1',
                instance=public_server_1.id,
                associate_with_private_ip=public_server_1.private_ip,
                vpc=True,
                tags={
                    'Name': 'infra eip 1 (front-back-autoscaling)',
                    'Creator': 'timc'
                })

# TODO move this to ALB when the time comes
eip_2 = ec2.Eip(resource_name='new-eip-2',
                instance=public_server_2.id,
                associate_with_private_ip=public_server_2.private_ip,
                vpc=True,
                tags={
                    'Name': 'infra eip 2 (front-back-autoscaling)',
                    'Creator': 'timc'
                })

# AWS: Maybe I should drop the route definition above, and use a
コード例 #5
0
ファイル: __main__.py プロジェクト: dieple/pulumi-practice
    associate_public_ip_address=False,
    key_name='sl-us-west-2',

    # TODO `Quiver`: `Pulumi > Questions > Adding tags forces EC2 replacement?`
    #   edit: I also changed the instance's `resource_name`
    tags={
        'Name': 'infra ec2',
        'Creator': 'timc'
    })

# TODO bug? If you include `associate_with_private_ip = server.private_ip` but
# leave off `instance = server.id`, the association is not created
eip = ec2.Eip(resource_name='new-eip',
              instance=server.id,
              associate_with_private_ip=server.private_ip,
              tags={
                  'Name': 'infra eip',
                  'Creator': 'timc'
              })

# stack exports
pulumi.export('vpcID', vpc.id)
pulumi.export('subnetID', subnet.id)
pulumi.export('internetGatewayID', igw.id)
pulumi.export('routeTableID', rt.id)
pulumi.export('routeID', route.id)
pulumi.export('bucket_name', bucket.bucket_domain_name)
pulumi.export('securityGroupID', sg.id)
pulumi.export('AMI', server.ami)
pulumi.export('instanceID', server.id)
pulumi.export('elasticIP', eip.public_ip)
コード例 #6
0
from storage import bucket
from access import userAccessKey
from security import mysqlNextcloudPassword, mysqlRootPassword

env = pulumi.get_stack()
config = pulumi.Config("nextcloud")
size = config.require("size")
keyPairName = config.require("keyPairName")
availabilityZone = config.require("availabilityZone")
volume_size_G = config.require("volume_size_G")
tmp_size_G = config.require("tmp_size_G")

# We first need to know our Instance IP (required in userData)
elastic_ip = ec2.Eip(f"nextcloud-elastic-ip-{env}",
                     # instance=instance.id
                     )

# We first need to generate the userData script by filling the fields in userData.sh
with open('userData.sh', 'r') as file:
    userScript = file.read()

userScript_final = pulumi.Output.all(
    bucket.id, userAccessKey.id, userAccessKey.secret,
    mysqlNextcloudPassword.result, mysqlRootPassword.result,
    elastic_ip.public_ip).apply(
        lambda l: userScript.replace('<BUCKET_NAME>', l[0]).
        replace('<USER_KEY>', l[1]).replace('<USER_SECRET>', l[2]).replace(
            '<MYSQL_NEXTCLOUD_PASSWORD>', l[3]).replace(
                '<MYSQL_ROOT_PASSWORD>', l[4]).replace('<ELASTIC_IP>', l[
                    5]).replace('<AWS_REGION>',
コード例 #7
0
def setup_vpc():
    # Create a VPC
    vpc_config = Config().require_object("vpc_config")
    vpc = ec2.Vpc("chatapp-vpc",
                  cidr_block=vpc_config['cidr'],
                  enable_dns_hostnames=True,
                  enable_dns_support=True)

    # Create public subnet to place NGW
    public_subnet = ec2.Subnet("PublicSubnet",
                               vpc_id=vpc.id,
                               cidr_block=vpc_config['public_subnet_cidr'],
                               availability_zone="ap-southeast-1a")

    # Create private subnets 1 and 2 for rds and redis clusters
    private_subnet_1 = ec2.Subnet(
        "PrivateSubnet1",
        vpc_id=vpc.id,
        cidr_block=vpc_config['private_subnet_1_cidr'],
        availability_zone="ap-southeast-1b")

    private_subnet_2 = ec2.Subnet(
        "PrivateSubnet2",
        vpc_id=vpc.id,
        cidr_block=vpc_config['private_subnet_2_cidr'],
        availability_zone="ap-southeast-1c")

    # Create internet gateway
    inet_gw = ec2.InternetGateway(
        "inet-gateway",
        vpc_id=vpc.id,
    )

    # create NAT gateway
    elastic_ip = ec2.Eip("eip1",
                         opts=ResourceOptions(delete_before_replace=True))
    nat_gw = ec2.NatGateway("nat-gateway",
                            subnet_id=public_subnet.id,
                            allocation_id=elastic_ip.id)

    # Create private routed route-table
    private_subnet_route_table = ec2.RouteTable("privatesubnetroutetable",
                                                routes=[{
                                                    "cidr_block": "0.0.0.0/0",
                                                    "gateway_id": nat_gw.id
                                                }],
                                                vpc_id=vpc.id)

    # Create public routed route-table
    public_subnet_route_table = ec2.RouteTable("publicsubnetroutetable",
                                               routes=[{
                                                   "cidr_block": "0.0.0.0/0",
                                                   "gateway_id": inet_gw.id
                                               }],
                                               vpc_id=vpc.id)

    # Attach route tables to subnets
    ec2.RouteTableAssociation("PrivateSubnetRT1",
                              subnet_id=private_subnet_1.id,
                              route_table_id=private_subnet_route_table.id)
    ec2.RouteTableAssociation("PrivateSubnetRT2",
                              subnet_id=private_subnet_2.id,
                              route_table_id=private_subnet_route_table.id)
    ec2.RouteTableAssociation("PublicSubnetRT",
                              subnet_id=public_subnet.id,
                              route_table_id=public_subnet_route_table.id)
    return dict(vpc=vpc, private_subnets=[private_subnet_1, private_subnet_2])
コード例 #8
0
ファイル: network.py プロジェクト: jarshwah/pulumi-aws-infra
    def _create_subnet(self, network_name, public_route_table, az_id):
        """
        Creates a subnet in the network with the given name and using the
        given public route table to access the internet. The new subnet
        is created in the AZ with the given AZ index.
        :param network_name: The name of the network being created
        :param public_route_table: The route table to connect this subnet to the internet
        :param az_id: The AZ ID for this new subnet
        :return: A tuple of a public route table that this subnet will use to connect to the
        internet and the new subnet itself. If this subnet is private, the route table will
        point to a public NAT gateway that is connected to the new private subnet.
        """
        # type: (str, ec2.RouteTable, int) -> (ec2.RouteTable, ec2.Subnet)
        subnet_name = "%s-%d" % (network_name, az_id)
        # Create the subnet for this AZ - either public or private
        subnet = ec2.Subnet(
            subnet_name,
            vpc_id=self.vpc_id,
            availability_zone=get_aws_az(az_id),
            cidr_block="10.10.%d.0/24" % az_id,
            map_public_ip_on_launch=not self.use_private_subnets,
            # Only assign public IP if we are exposing public subnets
            tags={
                "Name": subnet_name,
            },
            __opts__=ResourceOptions(parent=self))

        # We will use a different route table for this subnet depending on
        # whether we are in a public or private subnet
        if self.use_private_subnets:
            # We need a public subnet for the NAT Gateway
            nat_name = "%s-nat-%d" % (network_name, az_id)
            nat_gateway_public_subnet = ec2.Subnet(
                nat_name,
                vpc_id=self.vpc_id,
                availability_zone=get_aws_az(az_id),
                # Use top half of the subnet space
                cidr_block="10.10.%d.0/24" % (az_id + 64),
                # Always assign a public IP in NAT subnet
                map_public_ip_on_launch=True,
                tags={"Name": nat_name},
                __opts__=ResourceOptions(parent=self))

            # And we need to route traffic from that public subnet to the Internet Gateway
            nat_gateway_routes = ec2.RouteTableAssociation(
                nat_name,
                subnet_id=nat_gateway_public_subnet.id,
                route_table_id=public_route_table.id,
                __opts__=ResourceOptions(parent=self))

            self.public_subnet_ids.append(nat_gateway_public_subnet.id)

            # We need an Elastic IP for the NAT Gateway
            eip = ec2.Eip(nat_name, __opts__=ResourceOptions(parent=self))

            # And we need a NAT Gateway to be able to access the Internet
            nat_gateway = ec2.NatGateway(
                nat_name,
                subnet_id=nat_gateway_public_subnet.id,
                allocation_id=eip.id,
                tags={"Name": nat_name},
                __opts__=ResourceOptions(parent=self,
                                         depends_on=[nat_gateway_routes]))

            nat_route_table = ec2.RouteTable(
                nat_name,
                vpc_id=self.vpc_id,
                routes=[{
                    "cidrBlock": "0.0.0.0/0",
                    "natGatewayId": nat_gateway.id
                }],
                tags={"Name": network_name},
                __opts__=ResourceOptions(parent=self))

            # Route through the NAT gateway for the private subnet
            return nat_route_table, subnet

        self.public_subnet_ids.append(subnet.id)
        return public_route_table, subnet
コード例 #9
0
ファイル: __main__.py プロジェクト: anantakjena/examples-1
    threshold=80,
    alarm_description="This metric monitors ec2 cpu utilization")

## DynamoDB
db = dynamodb.Table(
    "mytable",
    attributes=[dynamodb.TableAttributeArgs(
        name="Id",
        type="S",
    )],
    hash_key="Id",
    read_capacity=1,
    write_capacity=1)

## EC2
eip = ec2.Eip("myeip")

security_group = ec2.SecurityGroup("mysecuritygroup",
                                   ingress=[
                                       ec2.SecurityGroupIngressArgs(
                                           protocol="tcp",
                                           from_port=80,
                                           to_port=80,
                                           cidr_blocks=["0.0.0.0/0"])
                                   ])

vpc = ec2.Vpc("myvpc", cidr_block="10.0.0.0/16")

igw = ec2.InternetGateway("myinternetgateway", vpc_id=vpc.id)

public_route_table = ec2.RouteTable("myroutetable",
コード例 #10
0
    route_table_id=rtb_pub.id
)

for i in subnets["public"]:
    ec2.RouteTableAssociation(
        f"{APP}-rtb-assoc-pub{i}",
        route_table_id=rtb_pub.id,
        subnet_id=subnets["public"][i]
    )

rtb_privs = []
if not ha:
    eip = ec2.Eip(
        f"{APP}-eip0",
        vpc=True,
        tags={
            'Name': f"{APP}-eip0",
            'Environment': _env
        }
    )
    ngw = ec2.NatGateway(
        f"{APP}-ngw0",
        allocation_id=eip.id,
        subnet_id=subnets["public"][0],
        tags={
            'Name': f"{APP}-ngw0",
            'Environment': _env
        }
    )
    rtb_priv = ec2.RouteTable(
        f"{APP}-rtb-priv0",
        vpc_id=vpc.id,
コード例 #11
0
    associate_public_ip_address=False,
    key_name='sl-us-west-2',

    # TODO `Quiver`: `Pulumi > Questions > Adding tags forces EC2 replacement?`
    #   edit: I also changed the instance's `resource_name`
    tags={
        'Name': 'infra public ec2 (front-rail-back-rail)',
        'Creator': 'timc'
    })

# TODO bug? If you include `associate_with_private_ip = server.private_ip` but
# leave off `instance = server.id`, the association is not created
eip = ec2.Eip(resource_name='new-eip',
              instance=public_server.id,
              associate_with_private_ip=public_server.private_ip,
              vpc=True,
              tags={
                  'Name': 'infra eip (front-rail-back-rail)',
                  'Creator': 'timc'
              })

# AWS: Maybe I should drop the route definition above, and use a
# MainRouteTableAssociation here. The main route table is sitting idle.

# TODO this needs to go out via NAT gateway
private_subnet_rt = ec2.RouteTable(
    resource_name='new-private-subnet-rt',
    vpc_id=vpc.id,
    tags={
        'Name': 'infra private route table (front-rail-back-rail)',
        'Creator': 'timc'
    })
コード例 #12
0
        subnet_id=public_subnet.id,
    )
    public_subnet_ids.append(public_subnet.id)

    #### private stuff

    private_subnet = ec2.Subnet(
        f"pulumi-private-subnet-{zone}",
        assign_ipv6_address_on_creation=False,
        vpc_id=vpc.id,
        map_public_ip_on_launch=False,
        cidr_block=private_subnet_cidr,
        availability_zone=zone,
        tags={"Name": f"pulumi-private-subnet-{zone}"},
    )
    eip = ec2.Eip(f"pulumi-eip-{zone}", tags={"Name": f"pulumi-eip-{zone}"})
    nat_gateway = ec2.NatGateway(
        f"pulumi-natgw-{zone}",
        subnet_id=public_subnet.id,
        allocation_id=eip.id,
        tags={"Name": f"pulumi-natgw-{zone}"},
    )
    private_rt = ec2.RouteTable(
        f"pulumi-private-rt-{zone}",
        vpc_id=vpc.id,
        routes=[{
            "cidr_block": "0.0.0.0/0",
            "gateway_id": nat_gateway.id
        }],
        tags={"Name": f"pulumi-private-rt-{zone}"},
    )
コード例 #13
0
    def __init__(
        self,
        name,
        opts=None,
    ):
        super().__init__("nuage:aws:DevelopmentEnvironment:VPC",
                         f"{name}VpcEnvironment", None, opts)

        vpc = ec2.Vpc(
            f"{name}Vpc",
            cidr_block="172.32.0.0/16",
            enable_dns_hostnames=True,
            enable_dns_support=True,
        )
        subnet_1 = ec2.Subnet(
            f"{name}VpcSubnetA",
            availability_zone="eu-west-1a",
            vpc_id=vpc.id,
            cidr_block="172.32.0.0/20",
            opts=ResourceOptions(depends_on=[vpc]),
        )
        subnet_2 = ec2.Subnet(
            f"{name}VpcSubnetB",
            availability_zone="eu-west-1b",
            vpc_id=vpc.id,
            cidr_block="172.32.16.0/20",
            opts=ResourceOptions(depends_on=[vpc]),
        )
        subnet_3 = ec2.Subnet(
            f"{name}VpcSubnetC",
            availability_zone="eu-west-1c",
            vpc_id=vpc.id,
            cidr_block="172.32.32.0/20",
            opts=ResourceOptions(depends_on=[vpc]),
        )

        private_subnet_1 = ec2.Subnet(
            f"{name}VpcPrivateSubnetA",
            availability_zone="eu-west-1a",
            vpc_id=vpc.id,
            cidr_block="172.32.48.0/20",
            opts=ResourceOptions(depends_on=[vpc]),
        )

        security_group = ec2.SecurityGroup(
            f"{name}SecurityGroup",
            vpc_id=vpc.id,
            opts=ResourceOptions(depends_on=[vpc]),
        )

        security_group_rule = ec2.SecurityGroupRule(
            f"{name}SSHRule",
            security_group_id=security_group.id,
            type="ingress",
            protocol="tcp",
            from_port=22,
            to_port=22,
            cidr_blocks=["0.0.0.0/0"],
        )

        security_group_rule = ec2.SecurityGroupRule(
            f"{name}InboundRule",
            security_group_id=security_group.id,
            type="ingress",
            protocol="all",
            from_port=0,
            to_port=65535,
            source_security_group_id=security_group.id,
        )
        security_group_rule = ec2.SecurityGroupRule(
            f"{name}OutboundRule",
            security_group_id=security_group.id,
            type="egress",
            protocol="all",
            from_port=0,
            to_port=65535,
            cidr_blocks=["0.0.0.0/0"],
        )

        subnets = [subnet_1, subnet_2, subnet_3]

        gateway = ec2.InternetGateway(
            f"{name}InternetGateway",
            vpc_id=vpc.id,
            opts=ResourceOptions(depends_on=[vpc]),
        )

        gateway_route = ec2.Route(
            f"{name}GatewayRoute",
            destination_cidr_block="0.0.0.0/0",
            gateway_id=gateway.id,
            route_table_id=vpc.default_route_table_id,
        )

        elastic_ip = ec2.Eip(f"{name}Eip",
                             vpc=True,
                             opts=ResourceOptions(depends_on=[gateway]))

        nat_gateway = ec2.NatGateway(
            f"{name}NatGateway",
            subnet_id=subnet_1.id,
            allocation_id=elastic_ip.id,
            opts=ResourceOptions(depends_on=[subnet_1, elastic_ip]),
        )

        private_route_table = ec2.RouteTable(
            f"{name}PrivateRouteTable",
            routes=[
                {
                    "cidr_block": "0.0.0.0/0",
                    "nat_gateway_id": nat_gateway.id,
                },
            ],
            vpc_id=vpc.id,
            opts=ResourceOptions(depends_on=[private_subnet_1]),
        )

        private_route_table_assoc = ec2.RouteTableAssociation(
            f"{name}PrivateRouteTableAssoc",
            route_table_id=private_route_table.id,
            subnet_id=private_subnet_1.id,
        )

        outputs = {
            "vpc": vpc,
            "security_group": security_group,
            "public_subnets": [subnet_1, subnet_2, subnet_3],
            "private_subnet": private_subnet_1,
            "nat_gateway": nat_gateway,
        }

        self.set_outputs(outputs)